2018年 C语言程序设计A卷答案

一、选择题答案

1、B 2、C 3、D 4、B 5、B 6、A 7、B 8、C 9、B 10、D 11、C 12、B 13、C 14、D 15、B 二、填空题答案 1、n=%d\\n m=%d\\n 2、i=5;i>=1;--i 3、1.0/(i*i) 4、 x avg/n

5、 {2,10,4,6},{1,5,2,3},{2,4,7,8},{5,1,3,2} 三、阅读题

1、 3 2、 67,D 3、 x=6,y=1 4、 123 5、 s=54321 6、四、程序设计题答案 1、 求两个整数中的较大者 #include int main() {

int max(int x,int y); int a,b,c;

scanf(\c=max(a,b);

printf(\return 0; }

int max(int x,int y) { int z; if(x>y)z=x; else z=y; return(z);

}

《C语言程序设计》考试试卷(A)参考答案 第1页 共2页

246 2、 求一维数组a中所有元素的平均值。

例如,当一维数组a中的元素为:10,4,2,7,3,12,5,34,5,9 #include void main() {

int a[10]={10,4,2,7,3,12,5,34,5,9},i; double aver,s; s = a[0];

for ( i=1; i<10; i++) s = s + a[i]; aver = s / i;

printf(\}

《C语言程序设计》考试试卷(A)参考答案 第2页 共2页

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4