当前位置:首页 > 计算机二级C语言上机题库及答案(100套)
{
for(j=0;j<3;j++)
printf(\ printf(\ }
fun(array); printf(\ out = fopen(\ for (i=0;i<3;i++) {
for(j=0;j<3;j++) {
printf(\ fprintf(out, \ }
printf(\ fprintf(out, \ }
fclose(out); } 答案是:
void fun(int array[3][3]) {
int i,j,temp; for(i=0;i<3;i++) for( j=0;j
{
temp=array[i][ j]; array[i][ j]=array[ j][i]; array[ j][i]=temp;
} }
第 19 套
填空题
给定程序的功能是计算 SCORE 中 M 个人的平均成绩 AVER,将 低于 AVER 的成绩放在 BELOW 中,通过函数名返回人数。 例如,当 SCORE={10,20,30,40,50,60,70,80,90}, M=9 时,函数返回人数应该是 4,BELOW={10,20,30,40}。 注意:部分源程序给出如下
请勿改动主函数 main 和其他函数中的任何内容,仅在
横线上填入所编写的若干表达式或语句。 试题程序:#include
#include
int fun(int score[], int m, int below[]) {
int i, j = 0; float aver = 0.0; for (i=0; i if (score[i] < aver) below[j++] = 1 ; return j; } main() { int i, n, below[9]; int score[9] = {10, 20, 30, 40, 50, 60, 70, 80, 90}; n = fun(score, 9, for (i=0; i 2 ); printf(\ printf(\} 第 1 处填空:score[i]或*(score+i) 第 2 处填空:below 第 3 处填空:below[i]或*(below+i) 3 ); 改错题 下列给定程序中函数 FUN 的功能是:从低位开始取出长整型变 量 S 中偶数位上的数依次构成一个新数放在 T 中。例如,当 S 中的数为 时,T 中的数为 642。 请改正程序中的错误,使它能得出正确结果。 注意:不要改动 MAIN 函数,不得增行或删行,也不要更改程 序的结构! 试题程序:#include #include long s1 = 10; s /= 10; *t = s; /********found********/ while (s < 0) { s = s/100; *t = s*s1+*t; s1 = s1*10; } } main() { long s, t; printf(\enter s:\ scanf(\ fun(s, &t); printf(\ } 第 1 处:void fun(long s,long t) 应改为 void fun(long s,long *t) 第 2 处:while(s<0)应改为 while(s>0)
共分享92篇相关文档