日本一本亚洲最大|日本午夜免费啪视频在|国产自产在线视频一区|亚洲福利精品视频

    <object id="4ihfc"></object>
      
      
    1. <object id="4ihfc"></object>
    2. 我要投稿 投訴建議

      計(jì)算機(jī)等級(jí)考試三級(jí)上機(jī)題庫(kù)練習(xí)及答案(5)

      時(shí)間:2022-07-23 17:44:06 計(jì)算機(jī)等級(jí) 我要投稿
      • 相關(guān)推薦

      2006年計(jì)算機(jī)等級(jí)考試三級(jí)上機(jī)題庫(kù)練習(xí)及答案(5)

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

      部分程序已經(jīng)給出。
      請(qǐng)勿改動(dòng)主函數(shù)main()、讀函數(shù)readDat()和寫函數(shù)writeDat()的內(nèi)容。
      #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不能打開(kāi)!007n");
      return;
      }
      CalValue();
      printf("文件in9.dat中共有正整數(shù)=%d個(gè)n",totNum);
      printf("符合條件的正整數(shù)的個(gè)數(shù)=%d個(gè)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://krishna123.com/

      【計(jì)算機(jī)等級(jí)考試三級(jí)上機(jī)題庫(kù)練習(xí)及答案(5)】相關(guān)文章:

      計(jì)算機(jī)等級(jí)考試三級(jí)(C語(yǔ)言)上機(jī)考試試題總結(jié)08-10

      2004年全國(guó)計(jì)算機(jī)等級(jí)考試三級(jí)C語(yǔ)言全真上機(jī)試題解析08-10

      計(jì)算機(jī)等級(jí)考試試題及答案08-09

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

      自考計(jì)算機(jī)上機(jī)基礎(chǔ)考試題及答案09-25

      計(jì)算機(jī)三級(jí)網(wǎng)絡(luò)技術(shù)上機(jī)考試題08-05

      2017年計(jì)算機(jī)等級(jí)考試試題及答案08-08

      2017全國(guó)計(jì)算機(jī)等級(jí)考試試題及答案08-07

      計(jì)算機(jī)一級(jí)考試題庫(kù)及答案08-09

      計(jì)算機(jī)等級(jí)一級(jí)考試填空題及答案08-06