![](https://csdnimg.cn/release/download_crawler_static/88062928/bga.jpg)
}
main ()
{ int a[N][N],n, i,j;
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");
}
do
{ n=rand () %10;
while (n>=5); /* 产生一个小于 5 的随机数 n* /
printf ("n=%4d\n", n);
fun (a, n);
printf ("*****THE RESULT*****\n");
for(i=0; i<N; i++)
{ for (j=0; j<N; j++)
printf ("%4d",a[i] [j] );
printf ("\n");
}
}
}
第 6 套
填空题 :请补充函数 fun() ,该函数的功能是:按‘ 0’到‘ 9’统计一个字符串中的
奇数数字字符各自出现的次数,结果保存在数组 num中。注意:不能使用字符串库函数。
例如:输入“ x=112385713.456+0.909*bc ”,结果为: 1=3,3=2,5=2,7=1,9=2。
注意:部分源程序给出如下。
请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun() 的横线上填入所编写
的若干表达式或语句。
试题程序:
#include<stdio. h>
#define N 1000
void fun(char *tt,int num[])
{ int i,j,bb[10];
char *p=tt;
for (i=0; i<10; i++)
{ num[i]=0;
bb[i]=0;
}
while( 【1】 )
{ if (*p>=' 0' &&*p<=' 9' )
【2】 ;