问答题
【参考答案】
(A)错误:int ave ,t=0;正确:float ave ,t=0.0;(B)错误:if(s[i]
(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
问答题
编程题下列程序定义了N×N的二维数组,并在主函数中自动赋值。请编写函数fun(int a[][N]),该函数的功能是:使数组右上半三角元素中的值全部置成0。例如a数组中的值为a=4 5 61 7 93 2 6,则返回主程序后a数组中的值应为0 0 01 0 03 2 0注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:#include #include #include #define N 5int fun (int a[][N]){}main(){ int a[N][N],i,j; clrscr(); printf( *****The array***** n ); for(i=0;i<N;i++) *产生一个随机的5*5矩阵* { for(j=0;j<N;j++) {a[i][j]=rand()%10; printf( %4d , a[i][j]); } printf( n ); } fun(a); printf( THE RESULT n ); for(i=0;i<N;i++) { for(j=0;j<N;j++) printf( %4d ,a[i][j]); printf( n ); }}
点击查看答案&解析
问答题
填空题请补充main函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组b中并输出,把其他字符保存在b[10]中。例如:当str1=“ab123456789cde090”时,结果为:0:2 1:1 2:1 3:1 4:1 5:1 6:1 7:1 8:1 9:2 other charactor:5注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:#include#includemain(){int i,b[11];char *str= ab123456789cde090 ;char *p=str;clrscr();printf( *** the origial data *** n );puts(str);for(i=0;i<11;i++)b[i]=0;while(*p){switch(【1】){case ’’0’’:b[0]++;break;case ’’1’’:b[1]++;break;case ’’2’’:b[2]++;break;case ’’3’’:b[3]++;break;case ’’4’’:b[4]++;break;case ’’5’’:b[5]++;break;case ’’6’’:b[6]++;break;case ’’7’’:b[7]++;break;case ’’8’’:b[8]++;break;case ’’9’’:b[9]++;break;【2】}【3】}printf( ****** the result ******** n );for(i=0;i<10;i++)printf( n%d:%d ,i,b[i]);printf( nother charactor:%d ,b[i]);}
点击查看答案&解析
相关试题
编程题下列程序定义了N×N的二维数组,并在...
填空题请补充main函数,该函数的功能是:从...