亚洲喷奶水中文字幕电影,日本aⅴ高清一区二区三区,欧美亚洲日本国产,欧美日韩亚洲中文字幕

<legend id="flx4p"><abbr id="flx4p"><thead id="flx4p"></thead></abbr></legend>

<mark id="flx4p"><thead id="flx4p"></thead></mark>

      我要投稿 投訴建議

      計算機等級考試三級上機題庫練習及答案(5)

      時間:2022-07-23 17:44:06 計算機等級 我要投稿
      • 相關推薦

      2006年計算機等級考試三級上機題庫練習及答案(5)

      第9題:
      已知在文件in9.dat中存在若干個(<200)四位數(shù)字的正整數(shù),函數(shù)readDat()讀取這若干個正整數(shù)并存入數(shù)組xx中。請編制函數(shù)CalValue(),其功能要求:(1)求出這個文件中共有多少個正整數(shù)totNum;(2)求這些數(shù)右移1位后,產生的新數(shù)是偶數(shù)的數(shù)的個數(shù)totCnt,以及滿足此條件的這些數(shù)(右移前的值)的算術平均值totPjz,最后調用函數(shù)writeDat()把所求的結果輸出到文件out9.dat中。

      部分程序已經給出。
      請勿改動主函數(shù)main()、讀函數(shù)readDat()和寫函數(shù)writeDat()的內容。
      #include
      #include
      #define MAXNUM 200
      int xx[MAXNUM];
      int totNum=0;
      int totCnt=0;
      double totPjz=0.0;
      int readDat(void);
      void writeDat(void);
      void CalValue(void)
      {
      }
      void main()
      {
      int i;
      clrscr();
      for(i=0;iif(readDat())
      {
      printf("數(shù)據(jù)文件in9.dat不能打開!007n");
      return;
      }
      CalValue();
      printf("文件in9.dat中共有正整數(shù)=%d個n",totNum);
      printf("符合條件的正整數(shù)的個數(shù)=%d個n",totCnt);
      printf("平均值=%.2fn",totPjz);
      writeDat();
      }
      int readDat(void)
      {
      FILE *fp;
      int i=0;
      if((fp=fopen("in9.dat","r"))==NULL)return 1;
      while(!feof(fp))
      {
      fscanf(fp,"%d,",&xx[i++]);
      }
      fclose(fp);
      return 0;
      }
      void writeDat(void)
      {
      FILE *fp;
      fp=fopen("out9.dat","w");
      fprintf(fp,"%dn%dn%6.2fn",totNum,totCnt,totPjz);
      fclose(fp);
      }
      【答案】
      void CalValue(void)
      {int i,data;
      for(i=0;i{
      if(!xx[i]) break;
      if(xx[i]>0) totNum++;
      data=xx[i]>>1;
      if(data%2==0)
      {totCnt++;totPjz+=xx[i];}
      }
      totPjz/=totCnt;
      }http://jzcjspjx.com/

      【計算機等級考試三級上機題庫練習及答案(5)】相關文章:

      計算機等級考試三級(C語言)上機考試試題總結08-10

      2004年全國計算機等級考試三級C語言全真上機試題解析08-10

      計算機等級考試試題及答案08-09

      全國計算機等級考試三級信息、網(wǎng)絡、數(shù)據(jù)庫上機編程題15道08-10

      自考計算機上機基礎考試題及答案09-25

      計算機三級網(wǎng)絡技術上機考試題08-05

      2017年計算機等級考試試題及答案08-08

      2017全國計算機等級考試試題及答案08-07

      計算機一級考試題庫及答案08-09

      計算機等級一級考試填空題及答案08-06