<pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

          <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

          <p id="bbfd9"></p>

          <p id="bbfd9"><cite id="bbfd9"></cite></p>

            <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

            <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
            <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>

            下半年計算機C語言考試題庫及答案

            時間:2024-10-21 21:54:12 計算機等級 我要投稿
            • 相關推薦

            2016年下半年計算機C語言考試題庫及答案

              1.下列給定程序中,函數fun的功能是計算如下公式  直到 ,并且把計算結果作為函數值返回。

            2016年下半年計算機C語言考試題庫及答案

              例如,若形參e的值為1e-3,則函數返回值為0.551690。請在下劃線處填入正確的內容并將下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              double fun(double e)

              { int i, k; double s, t, x;

              s=0; k=1; i=2;

              /**********found**********/

              x=__1__/4;

              /**********found**********/

              while(x __2__ e)

              { s=s+k*x;

              k=k* (-1);

              t=2*i;

              /**********found**********/

              x=__3__/(t*t);

              i++;

              }

              return s;

              }

              main()

              { double e=1e-3;

              printf("\nThe result is: %f\n",fun(e));

              }

              【參考答案】

              (1)3.0或(double)3  (2)>  (3) (t+1)

              2. 下列給定程序中,函數fun的功能是:計算如下公式前n項的和并作為函數值返回。

              例如,當形參n的值為10時,函數返回值為9.612558。

              請在下劃線處填入正確的內容并將下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              double fun(int n)

              { int i; double s, t;

              /**********found**********/

              s=__1__;

              /**********found**********/

              for(i=1; i<=__2__; i++)

              { t=2.0*i;

              /**********found**********/

              s=s+(2.0*i-1)*(2.0*i+1)/__3__;

              }

              return s;

              }

              main()

              { int n=-1;

              while(n<0)

              { printf("Please input(n>0): "); scanf("%d",&n); }

              printf("\nThe result is: %f\n",fun(n));

              }

              【參考答案】

              (1) 0  (2) n  (3) (t*t)

              3.給定程序中,函數fun的功能是:統計形參s所指的字符串中數字字符出現的次數,并存放在形參t所指的變量中,最后在主函數中輸出。例如,若形參s所指的字符串為abcdef35adgh3kjsdf7,則輸出結果為4。

              請在下劃線處填入正確內容并將下劃線刪除,使程序得出正確的結果。....

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              void fun(char *s, int *t)

              { int i, n;

              n=0;

              /**********found**********/

              for(i=0; ___1___ !=0; i++)

              /**********found**********/

              if(s[i]>='0'&&s[i]<= ___2___ ) n++;

              /**********found**********/

              ___3___ ;

              }

              main()

              { char s[80]="abcdef35adgh3kjsdf7";

              int t;

              printf("\nThe original string is : %s\n",s);

              fun(s,&t);

              printf("\nThe result is : %d\n",t);

              }

              【參考答案】

              (1) s[i]  (2) '9'  (3)*t=n

              4.下列給定程序中,函數fun的功能是:把形參a所指數組中的奇數按原順序依次存放到a[0]、a[1]、a[2]、……中,把偶數從數組中刪除,奇數個數通過函數值返回。

              例如:若a所指數組中的數據最初排列為:9、1、4、2、3、6、5、8、7,刪除偶數后a所指數組中的數據為:9、1、3、5、7,返回值為5。

              請在下劃線處填入正確的內容并將下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              #define N 9

              int fun(int a[], int n)

              { int i,j;

              j = 0;

              for (i=0; i

              /**********found**********/

              if (a[i]%2==___1___)

              {

              /**********found**********/

              a[j] = a[i]; ___2___;

              }

              /**********found**********/

              return ___3___;

              }

              main()

              { int b[N]={9,1,4,2,3,6,5,8,7}, i, n;

              printf("\nThe original data :\n");

              for (i=0; i

              printf("\n");

              n = fun(b, N);

              printf("\nThe number of odd : %d \n", n);

              printf("\nThe odd number :\n");

              for (i=0; i

              printf("\n");

              }

              【參考答案】

              (1)1  (2) j++  (3)j

              5.下列給定程序中,函數fun的功能是:將形參n中,各位上為偶數的數取出,并按原來從高位到低位相反的順序組成一個新數,作為函數值返回。

              例如,輸入一個整數27638496,函數返回值為64862。

              請在下劃線處填入正確的內容并將下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              unsigned long fun(unsigned long n)

              { unsigned long x=0; int t;

              while(n)

              { t=n%10;

              /**********found**********/

              if(t%2==____1____)

              /**********found**********/

              x=____2____+t;

              /**********found**********/

              n=____3____;

              }

              return x;

              }

              main()

              { unsigned long n=-1;

              while(n>99999999||n<0)

              { printf("Please input(0

              printf("\nThe result is: %ld\n",fun(n));

              }

              【參考答案】

              (1)0  (2) 10*x (3)n/10

              6.下列給定程序中,函數fun的功能是:把形參a所指數組中的最小值放在元素a[0]中,接著把a所指數組中的最大值放在a[1]元素中;再把a所指數組元素中的次小值放在a[2]中,把a所指數組元素中的次大值放在a[3],以此類推。

              例如,若a所指數組中的數據最初排列為:9、1、4、2、3、6、5、8、7;則按規則移動后,數據排列為:1、9、2、8、3、7、4、6、5。形參n中存放a所指數組中數據的個數。

              規定fun函數中的max存放當前所找的最大值,px存放當前所找最大值的下標。

              請在下劃線處填入正確的內容并將下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不行更改程序的結構!

              # include

              #define N 9

              void fun(int a[], int n)

              { int i,j, max, min, px, pn, t;

              for (i=0; i

              {

              /**********found**********/

              max = min = ___1___;

              px = pn = i;

              for (j=i+1; j

              /**********found**********/

              if (max<___2___)

              { max = a[j]; px = j; }

              /**********found**********/

              if (min>___3___)

              { min = a[j]; pn = j; }

              }

              if (pn != i)

              { t = a[i]; a[i] = min; a[pn] = t;

              if (px == i) px =pn;

              }

              if (px != i+1)

              { t = a[i+1]; a[i+1] = max; a[px] = t; }

              }

              }

              main()

              { int b[N]={9,1,4,2,3,6,5,8,7}, i;

              printf("\nThe original data :\n");

              for (i=0; i

              printf("\n");

              fun(b, N);

              printf("\nThe data after moving :\n");

              for (i=0; i

              printf("\n");

              }

              【參考答案】

              (1) a[i]  (2) a[j]  (3) a[j]

              7.下列給定程序中,函數fun的功能是進行數字字符轉換。若形參ch中是數字字符'0'~'9',則將'0'轉換成'9','1'轉換成'8','2'轉換成'7',……,'9'轉換成'0';若是其它字符則保持不變;并將轉換后的結果作為函數值返回。

              請在下劃線處填入正確的內容并將下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              /**********found**********/

              ___1___ fun(char ch)

              {

              /**********found**********/

              if (ch>='0' && ___2___)

              /**********found**********/

              return '9'- (ch-___3___);

              return ch ;

              }

              main()

              { char c1, c2;

              printf("\nThe result :\n");

              c1='2'; c2 = fun(c1);

              printf("c1=%c c2=%c\n", c1, c2);

              c1='8'; c2 = fun(c1);

              printf("c1=%c c2=%c\n", c1, c2);

              c1='a'; c2 = fun(c1);

              printf("c1=%c c2=%c\n", c1, c2);

              }

              【參考答案】

              (1) char (2) ch<='9' (3)'0'

              8.下列給定程序中,函數fun的功能是:求ss所指字符串數組中長度最短的字符串所在的行下標,作為函數值返回,并把其串長放在形參n所指的變量中。ss所指字符串數組中共有M個字符串,且串長

              請在下劃線處填入正確的內容并將下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              #include

              #define M 5

              #define N 20

              int fun(char (*ss)[N], int *n)

              { int i, k=0, len= N;

              /**********found**********/

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

              { len=strlen(ss[i]);

              if(i==0) *n=len;

              /**********found**********/

              if(len ___2___ *n)

              { *n=len;

              k=i;

              }

              }

              /**********found**********/

              return(___3___);

              }

              main()

              { char ss[M][N]={"shanghai","guangzhou","beijing","tianjing","chongqing"};

              int n,k,i;

              printf("\nThe original strings are :\n");

              for(i=0;i

              k=fun(ss,&n);

              printf("\nThe length of shortest string is : %d\n",n);

              printf("\nThe shortest string is : %s\n",ss[k]);

              }

              【參考答案】

              (1) M  (2) <  (3) k


            更多計算機二級相關試題推薦:

            1.2016年9月計算機二級C語言試題題庫

            2.計算機二級C語言筆試歷年真題及答案

            3.2016下半年計算機二級C語言考試試題及答案

            4.計算機二級C語言新增無紙化真題試卷

            5.2016年9月計算機二級C語言選擇題及答案

            6.2016下半年計算機二級C語言預測試題及答案

            7.計算機二級C語言試題及答案2016

            8.計算機二級C語言考試上機沖刺試題及答案

            9.計算機二級c語言題庫2016

            10.9月計算機二級c語言試題及答案

              9.下列給定程序中,函數fun的功能是:將s所指字符串中的所有數字字符移到所有非數字字符之后,并保持數字字符串和非數字字符串原有的次序。

              例如,s所指的字符串為def35adh3kjsdf7,執行后結果為defadhajsdf3537。

              請在程序的下劃線處填入正確的內容把下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              void fun(char *s)

              { int i, j=0, k=0; char t1[80], t2[80];

              for(i=0; s[i]!='\0'; i++)

              if(s[i]>='0' && s[i]<='9')

              {

              /**********found**********/

              t2[j]=s[i]; ___1___;

              }

              else t1[k++]=s[i];

              t2[j]=0; t1[k]=0;

              /**********found**********/

              for(i=0; i

              /**********found**********/

              for(i=0; i<___3___; i++) s[k+i]=t2[i];

              }

              main()

              { char s[80]="ba3a54j7sd567sdffs";

              printf("\nThe original string is : %s\n",s);

              fun(s);

              printf("\nThe result is : %s\n",s);

              }

              【參考答案】

              (1)j++或j+=1或++或j=j+1

              (2)s[i]=t1[i]  (3) j

              10下列給定程序中已建立一個帶頭結點的單向鏈表,鏈表中的各結點按結點數據域中的數據遞增有序鏈接。函數fun的功能是:把形參x的值放入一個新結點并插入鏈表中,使插入后各結點數據域中的數據仍保持遞增有序。

              請在下劃線處填入正確的內容并將下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              #include

              #define N 8

              typedef struct list

              { int data;

              struct list *next;

              } SLIST;

              void fun( SLIST *h, int x)

              { SLIST *p, *q, *s;

              s=(SLIST *)malloc(sizeof(SLIST));

              /**********found**********/

              s->data=___1___;

              q=h;

              p=h->next;

              while(p!=NULL && x>p->data) {

              /**********found**********/

              q=___2___;

              p=p->next;

              }

              s->next=p;

              /**********found**********/

              q->next=___3___;

              }

              SLIST *creatlist(int *a)

              { SLIST *h,*p,*q; int i;

              h=p=(SLIST *)malloc(sizeof(SLIST));

              for(i=0; i

              { q=(SLIST *)malloc(sizeof(SLIST));

              q->data=a[i]; p->next=q; p=q;

              }

              p->next=0;

              return h;

              }

              void outlist(SLIST *h)

              { SLIST *p;

              p=h->next;

              if (p==NULL) printf("\nThe list is NULL!\n");

              else

              { printf("\nHead");

              do { printf("->%d",p->data); p=p->next; } while(p!=NULL);

              printf("->End\n");

              }

              }

              main()

              { SLIST *head; int x;

              int a[N]={11,12,15,18,19,22,25,29};

              head=creatlist(a);

              printf("\nThe list before inserting:\n"); outlist(head);

              printf("\nEnter a number : "); scanf("%d",&x);

              fun(head,x);

              printf("\nThe list after inserting:\n"); outlist(head);

              }

              【參考答案】

              (1)x  (2)p  (3)s

              11.下列給定程序中,函數fun的功能是:將形參a所指數組中的前半部分元素中的值與后半部分元素中的值對換。形參n中存放數組中數據的個數,若n為奇數,則中間的元素不動。

              例如:若a所指數組中的數據為:1、2、3、4、5、6、7、8、9,則調換后為:6、7、8、9、5、1、2、3、4。

              請在下劃線處填入正確的內容并將下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              #define N 9

              void fun(int a[], int n)

              { int i, t, p;

              /**********found**********/

              p = (n%2==0)?n/2:n/2+___1___;

              for (i=0; i

              {

              t=a[i];

              /**********found**********/

              a[i] = a[p+___2___];

              /**********found**********/

              ___3___ = t;

              }

              }

              main()

              { int b[N]={1,2,3,4,5,6,7,8,9}, i;

              printf("\nThe original data :\n");

              for (i=0; i

              printf("\n");

              fun(b, N);

              printf("\nThe data after moving :\n");

              for (i=0; i

              printf("\n");

              }

              【參考答案】

              (1)1  (2) i  (3) a[p+i]或*(a+p+i)

              12.下列給定程序中,函數fun的功能是:從形參ss所指字符串數組中,刪除所有串長超過k的字符串,函數返回剩余字符串的個數。ss所指字符串數組中共有N個字符串,且串長小于M。

              請在下劃線處填入正確的內容并將下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              #include

              #define N 5

              #define M 10

              int fun(char (*ss)[M], int k)

              { int i,j=0,len;

              /**********found**********/

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

              { len=strlen(ss[i]);

              /**********found**********/

              if(len<= __2__)

              /**********found**********/

              strcpy(ss[j++],__3__);

              }

              return j;

              }

              main()

              { char x[N][M]={"Beijing","Shanghai","Tianjing","Nanjing","Wuhan"};

              int i,f;

              printf("\nThe original string\n\n");

              for(i=0;i

              f=fun(x,7);

              printf("The string witch length is less than or equal to 7 :\n");

              for(i=0; i

              }

              【參考答案】

              (1) N  (2) k  (3) ss[i]

              13.下列給定程序中,函數fun的功能是:把形參s所指字符串中下標為奇數的字符右移到下一個奇數位置,最右邊被移出字符串的字符繞回放到第一個奇數位置,下標為偶數的字符不動(注:字符串的長度大于等于2)。

              例如,形參s所指字符串為abcdefgh,執行結果為ahcbedgf。

              請在下劃線處填入正確的內容并將下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              void fun(char *s)

              { int i, n, k; char c;

              n=0;

              for(i=0; s[i]!='\0'; i++) n++;

              /**********found**********/

              if(n%2==0) k=n-___1___ ;

              else k=n-2;

              /**********found**********/

              c=___2___ ;

              for(i=k-2; i>=1; i=i-2) s[i+2]=s[i];

              /**********found**********/

              s[1]=___3___ ;

              }

              main()

              { char s[80]="abcdefgh";

              printf("\nThe original string is : %s\n",s);

              fun(s);

              printf("\nThe result is : %s\n",s);

              }

              【參考答案】

              (1) 1  (2) s[k]或*(s+k)  (3) c

              14.下列給定程序中,函數fun的功能是:在形參ss所指字符串數組中查找與形參t所指字符串相同的串,找到后返回該串在字符串數組中的位置(即下標值),若未找到則返回-1。ss所指字符串數組中共有N個內容不同的字符串,且串長小于M。

              請在下劃線處填入正確的內容并將下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              #include

              #define N 5

              #define M 8

              int fun(char (*ss)[M],char *t)

              { int i;

              /**********found**********/

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

              /**********found**********/

              if(strcmp(ss[i],t)==0 ) return __2__ ;

              return -1;

              }

              main()

              { char ch[N][M]={"if","while","switch","int","for"},t[M];

              int n,i;

              printf("\nThe original string\n\n");

              for(i=0;i

              printf("\nEnter a string for search: "); gets(t);

              n=fun(ch,t);

              /**********found**********/

              if(n== __3__) printf("\nDon't found!\n");

              else printf("\nThe position is %d .\n",n);

              }

              【參考答案】

              (1)N  (2)i  (3) -1

              15.下列給定程序中已建立了一個帶頭結點的單向鏈表,在main函數中將多次調用fun函數,每調用一次,輸出鏈表尾部結點中的數據,并釋放該結點,使鏈表縮短。

              請在下劃線處填入正確的內容并將下劃線刪除,使程序得出正確的結果。

              注意:部分源程序在文件BLANK1.C中。

              不得增行或刪行,也不得更改程序的結構!

              #include

              #include

              #define N 8

              typedef struct list

              { int data;

              struct list *next;

              } SLIST;

              void fun( SLIST *p)

              { SLIST *t, *s;

              t=p->next; s=p;

              while(t->next != NULL)

              { s=t;

              /**********found**********/

              t=t->___1___;

              }

              /**********found**********/

              printf(" %d ",___2___);

              s->next=NULL;

              /**********found**********/

              free(___3___);

              }

              SLIST *creatlist(int *a)

              { SLIST *h,*p,*q; int i;

              h=p=(SLIST *)malloc(sizeof(SLIST));

              for(i=0; i

              { q=(SLIST *)malloc(sizeof(SLIST));

              q->data=a[i]; p->next=q; p=q;

              }

              p->next=0;

              return h;

              }

              void outlist(SLIST *h)

              { SLIST *p;

              p=h->next;

              if (p==NULL) printf("\nThe list is NULL!\n");

              else

              { printf("\nHead");

              do { printf("->%d",p->data); p=p->next; } while(p!=NULL);

              printf("->End\n");

              }

              }

              main()

              { SLIST *head;

              int a[N]={11,12,15,18,19,22,25,29};

              head=creatlist(a);

              printf("\nOutput from head:\n"); outlist(head);

              printf("\nOutput from tail: \n");

              while (head->next != NULL){

              fun(head);

              printf("\n\n");

              printf("\nOutput from head again :\n"); outlist(head);

              }

              }

              【參考答案】

              (1)next  (2) t->data  (3) t


            更多計算機二級相關試題推薦:

            1.2016年9月計算機二級C語言試題題庫

            2.計算機二級C語言筆試歷年真題及答案

            3.2016下半年計算機二級C語言考試試題及答案

            4.計算機二級C語言新增無紙化真題試卷

            5.2016年9月計算機二級C語言選擇題及答案

            6.2016下半年計算機二級C語言預測試題及答案

            7.計算機二級C語言試題及答案2016

            8.計算機二級C語言考試上機沖刺試題及答案

            9.計算機二級c語言題庫2016

            10.9月計算機二級c語言試題及答案

            【下半年計算機C語言考試題庫及答案】相關文章:

            計算機二級c語言題庫及答案03-28

            國家計算機二級c語言題庫及答案03-08

            全國計算機二級c語言題庫試題及答案03-29

            計算機C語言試題及答案02-25

            2017年計算機二級c語言題庫試題及答案03-28

            計算機二級C語言考試真題及答案09-30

            計算機二級C語言考試試題及答案03-08

            2017計算機二級考試C語言習題及答案03-10

            計算機二級C語言題庫2016最新03-29

                    <pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

                    <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

                    <p id="bbfd9"></p>

                    <p id="bbfd9"><cite id="bbfd9"></cite></p>

                      <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

                      <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
                      <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>
                      飘沙影院