• <sub id="h4knl"><ol id="h4knl"></ol></sub>
    <sup id="h4knl"></sup>
      <sub id="h4knl"></sub>

      <sub id="h4knl"><ol id="h4knl"><em id="h4knl"></em></ol></sub><s id="h4knl"></s>
      1. <strong id="h4knl"></strong>

      2. 計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)考試試題「有答案」

        時(shí)間:2024-09-13 09:10:21 網(wǎng)絡(luò)技術(shù) 我要投稿

        2017計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)考試精選試題「有答案」

          1.下列程序的功能是:利用以下所示的簡(jiǎn)單迭代方法求方程:

        2017計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)考試精選試題「有答案」

          cos (x) -x=0的一個(gè)實(shí)根。

          xn+1=cos(xn )

          迭代步驟如下:

          (1)取x1初值為0.0。

          (2)x0=x1,把x1的值賦給x0。

          (3)x1=cos(x0),求出一個(gè)新的x1。

          (4)若x0-x1的絕對(duì)值小于0.000001,執(zhí)行步驟(5),否則執(zhí)行步驟(2)。

          (5)所求x1就是方程cos(x)-x=0的一個(gè)實(shí)根,作為函數(shù)值返回。

          請(qǐng)編寫函數(shù)countValue ( )實(shí)現(xiàn)程序要求,最后調(diào)用函數(shù)writeDAT( )把結(jié)果輸出到文件out9.dat中。

          注意:部分源程序已給出。

          請(qǐng)勿改動(dòng)主函數(shù)main()和寫函數(shù)writeDAT()的內(nèi)容。

          #include

          #include

          #include

          void writeDAT();

          float countValue( )

          {

          float x0,x1=0.0; /*定義兩個(gè)浮點(diǎn)型變量進(jìn)行迭代*/

          while(1) /*無條件循環(huán)*/

          {

          x0=x1; /*將x1賦值給x0*/

          x1=cos(x0); /*求出新的x1*/

          if(fabs(x0-x1)<1e-6) break; /*若x0-x1的絕對(duì)值小于0.000001,則結(jié)束循環(huán)*/

          }

          return x1; /*返回 x1的值*/

          }

          void main( )

          {

          system("CLS");

          printf("實(shí)根=%f\n",countValue( ));

          printf("%f\n",cos(countValue( ))-countValue( ));

          writeDAT( );

          }

          void writeDAT( )

          {

          FILE *wf;

          wf=fopen("out9.dat","w");

          fprintf(wf,"%f\n",countValue( ));

          fclose(wf);

          }

          2.請(qǐng)編寫函數(shù)void countValue(int *a,int *n),它的功能是:求出1到1000之內(nèi)能被7或11整除但不能同時(shí)被7和11整除的所有整數(shù)并存放在數(shù)組a中,并通過n返回這些數(shù)的個(gè)數(shù)。

          注意:部分源程序已給出。

          請(qǐng)勿改動(dòng)主函數(shù)main()和寫函數(shù)writeDAT()的內(nèi)容。

          #include

          #include

          void writeDAT();

          void countValue(int *a,int *n)

          {

          int i; /*定義循環(huán)控制變量*/

          *n=0 ; /*初始化計(jì)數(shù)器變量*/

          for(i=1;i<=1000;i++) /*在這個(gè)范圍內(nèi)尋找符合條件的數(shù)*/

          if((i%7==0 && i%11!=0)||(i%7!=0 && i%11==0))

          /*如果當(dāng)前的數(shù)可以被7整除而不可以被11整除,或者可以被11整除而不可以被7整除*/

          {

          *a=i; /*保存符合條件的數(shù)*/

          *n=*n+1; /*統(tǒng)計(jì)個(gè)數(shù)*/

          a++;

          }

          }

          void main()

          {

          int aa[1000],n,k;

          system("CLS");

          countValue(aa,&n);

          for(k=0;k

          if((k+1) %10 ==0)

          {

          printf("%5d",aa[k]);

          printf("\n");

          }

          else printf("%5d",aa[k]);

          writeDAT();

          }

          void writeDAT()

          {

          int aa[1000],n,k;

          FILE *fp;

          fp=fopen("out10.dat","w");

          countValue(aa,&n);

          for(k=0;k

          if((k+1)%10==0)

          {

          fprintf(fp,"%5d",aa[k]);

          fprintf(fp,"\n");

          }

          else fprintf(fp,"%5d",aa[k]);

          fclose(fp);

          }

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

          注意:部分源程序已給出。

          請(qǐng)勿改動(dòng)主函數(shù)main()、讀函數(shù)ReadDat()和寫函數(shù)WriteDat()的內(nèi)容。

          #include

          #include

          #define MAXNUM 200

          int xx[MAXNUM] ;

          int totNum = 0 ; /* 文件IN11.DAT中共有多少個(gè)正整數(shù) */

          int totCnt = 0 ; /* 符合條件的正整數(shù)的個(gè)數(shù) */

          double totPjz = 0.0 ; /* 平均值 */

          int ReadDat(void) ;

          void Writedat(void) ;

          void CalValue(void)

          {

          int i; /*定義循環(huán)控制變量*/

          int data; /*用于保存處理后產(chǎn)生的新數(shù)*/

          for(i=0;i<200;i++) /*逐個(gè)取數(shù)組xx中的數(shù)進(jìn)行統(tǒng)計(jì)*/

          if(xx[i]>0) /*判斷是否正整數(shù)*/

          {

          totNum++; /*統(tǒng)計(jì)正整數(shù)的個(gè)數(shù)*/

          data=xx[i]>>1; /*將數(shù)右移一位*/

          if(data%2==0) /*如果產(chǎn)生的新數(shù)是偶數(shù)*/

          {

          totCnt++; /*統(tǒng)計(jì)這些數(shù)的個(gè)數(shù)*/

          totPjz+=xx[i]; /*并將滿足條件的原數(shù)求和*/

          }

          }

          totPjz/=totCnt; /*求滿足條件的這些數(shù)(右移前的值)的算術(shù)平均值*/

          }

          void main()

          {

          int i ;

          system("CLS");

          for(i = 0 ; i < MAXNUM ; i++)

          xx[i] = 0 ;

          if (ReadDat ())

          {

          printf("數(shù)據(jù)文件IN11.DAT不能打開!\007\n");

          return ;

          }

          CalValue() ;

          printf("文件IN11.DAT中共有正整數(shù)= %d 個(gè)\n", totNum);

          printf("符合條件的正整數(shù)的個(gè)數(shù)= %d 個(gè)\n", totCnt);

          printf("平均值=%.2lf\n", totPjz);

          Writedat() ;

          }

          int ReadDat(void)

          {

          FILE *fp;

          int i = 0 ;

          if((fp = fopen ("IN11.DAT", "r")) == NULL)

          return 1 ;

          while(! feof(fp))

          {

          fscanf(fp, "%d,", &xx[i++]) ;

          }

          fclose(fp) ;

          return 0 ;

          }

          void Writedat(void)

          {

          FILE *fp;

          fp = fopen("OUT11.DAT", "w") ;

          fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;

          fclose(fp) ;

          }

          4.已知數(shù)據(jù)文件IN12.DAT中存有300個(gè)4位數(shù),并已調(diào)用讀函數(shù)readDat()把這些數(shù)存入數(shù)組a中。請(qǐng)編制函數(shù)jsValue(),其功能是:求出千位數(shù)上的數(shù)加個(gè)位數(shù)上的數(shù)等于百位數(shù)上的數(shù)加十位數(shù)上的數(shù)的個(gè)數(shù)cnt,再把所有滿足此條件的4位數(shù)依次存入數(shù)組b中,然后對(duì)數(shù)組b的4位數(shù)按從小到大的順序進(jìn)行排序,最后調(diào)用寫函數(shù)writeDat()把數(shù)組b中的數(shù)輸出到OUT12.DAT文件中。

          例如:6712,6+2=7+1,則該數(shù)滿足條件,存入數(shù)組b中,且個(gè)數(shù)cnt=cnt+1。

          8129,8+9≠1+2,則該數(shù)不滿足條件,忽略。

          注意:部分源程序已給出。

          程序中已定義數(shù)組:a[300],b[300],已定義變量:cnt。

          請(qǐng)勿改動(dòng)主函數(shù)main()、讀函數(shù)readDat()和寫函數(shù)writeDat()的內(nèi)容。

          #include

          int a[300], b[300], cnt=0;

          void readDat();

          void writeDat();

          void jsValue()

          {

          int i,j; /*定義循環(huán)控制變量*/

          int a1,a2,a3,a4; /*定義變量保存4位數(shù)的每位數(shù)字*/

          int temp; /*定義數(shù)據(jù)交換時(shí)的暫存變量*/

          for(i=0;i<300;i++) /*逐個(gè)取每一個(gè)4位數(shù)*/

          {

          a4=a[i]/1000; /*求4位數(shù)的千位數(shù)字*/

          a3=a[i]%1000/100; /*求4位數(shù)的百位數(shù)字*/

          a2=a[i]%100/10; /*求4位數(shù)的十位數(shù)字*/

          a1=a[i]%10; /*求4位數(shù)的個(gè)位數(shù)字*/

          if(a4+a1==a3+a2) /*如果千位數(shù)加個(gè)位數(shù)等于百位數(shù)加十位數(shù)*/

          {

          b[cnt]=a[i]; /*將滿足條件的數(shù)存入數(shù)組b中*/

          cnt++; /*統(tǒng)計(jì)滿足條件的數(shù)的個(gè)數(shù)cnt*/

          }

          }

          for(i=0;i

          for(j=i+1;j

          if(b[i]>b[j])

          {

          temp=b[i];

          b[i]=b[j];

          b[j]=temp;

          }

          }

          void main()

          {

          int i;

          readDat();

          jsValue();

          writeDat();

          printf("cnt=%d\n", cnt);

          for(i=0; i

          printf("b[%d]=%d\n", i, b[i]);

          }

          void readDat()

          {

          FILE *fp;

          int i;

          fp = fopen("IN12.DAT", "r");

          for(i=0; i<300; i++)

          fscanf(fp, "%d,", &a[i]);

          fclose(fp);

          }

          void writeDat()

          {

          FILE *fp;

          int i;

          fp = fopen("OUT12.DAT", "w");

          fprintf (fp, "%d\n",cnt);

          for(i=0; i

          fprintf(fp, "%d,\n", b[i]);

          fclose(fp);

          }

        【計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)考試試題「有答案」】相關(guān)文章:

        2017計(jì)算機(jī)三級(jí)考試網(wǎng)絡(luò)技術(shù)復(fù)習(xí)試題「有答案」09-01

        計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)考試題附答案08-12

        計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)考試題「附答案」06-17

        2017計(jì)算機(jī)與網(wǎng)絡(luò)技術(shù)試題「附答案」09-10

        2017計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)考試模擬試題「附答案」10-07

        2017計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)考試訓(xùn)練試題「附答案」10-14

        2017年計(jì)算機(jī)等級(jí)網(wǎng)絡(luò)技術(shù)考試試題及答案09-05

        2017職稱計(jì)算機(jī)考試Excel試題「有答案」09-08

        計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)模擬試題及答案10-09

        2017計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)考試練習(xí)試題「附答案」10-14

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码
      3. <sub id="h4knl"><ol id="h4knl"></ol></sub>
        <sup id="h4knl"></sup>
          <sub id="h4knl"></sub>

          <sub id="h4knl"><ol id="h4knl"><em id="h4knl"></em></ol></sub><s id="h4knl"></s>
          1. <strong id="h4knl"></strong>

          2. 亚洲中文aⅴ中文字幕每天被 | 中文字幕一区二区三区日韩精品 | 亚洲国产综合精品中文字幕 | 中文字幕一区二区精品区 | 日韩亚州欧美中文 | 亚洲综合狠狠99婷婷 |