計算機等級

當前位置 /首頁/IT認證/計算機等級/列表

2016年計算機二級c語言題庫及答案

9月全國計算機等級考試在即,yjbys小編為了幫助大家能順利進行備考9月24-27日計算機二級考試,特提供以下2016年9月計算機二級C語言考前模擬題供各位參考。

2016年計算機二級c語言題庫及答案

  程式填空題

1、求主次對角線之和。

main()

{static int a[ ][3]={9,7,5,1,2,4,6,8};

int I,j,s1=0,s2=0;

for(I=0;I<3;I++)

for(j=0;j<3;j++)

{if(__________)

s1=s1+a[I][j];

if( __________ )

s2=s2+a[I][j];

}

printf(“%dn%dn”,s1,s2);

}

2、從鍵盤上輸入10個數,求其平均值。

main()

{int i;

float f,sum;

for(i=1,sum=0.0;i<11;i++)

{__________;

__________ ;

}

printf(“average=%fn”,sum/10);

}

3、以下程式是建立一個名為myfile的`檔案,並把從鍵盤輸入的字元存入該檔案,當鍵盤上輸入結束時關閉該檔案。

#include

main()

{

FILE *fp;

char c;

fp=__________;

do

{

c=getchar();

fputs(c,fp);

}while(c!=EOF);

__________; ;

}

參考答案

1、I==j I+j==2

2、scanf(“%f”,&f); sum+=f;

3、fopen(“myfile”,w) fclose(fp);


TAG標籤:題庫 計算機 語言 二級 #