请补充fun函数,该函数的功能是:按‘0’到‘9’统计
请补充fun函数,该函数的功能是:按‘0’到‘9’统计一个字符串中的 奇数数字字符各自出现的次数,结果保存在数组num中。注意:不能 使用字符串库函数。 例如,输入“x=1123.456+0.909*bc”,结果为:1=2,3=1,5=1,7=0,9=2。注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横 线上填入所编写的若干表达式或语句。
/**********code.c**********/
#include <conio.h>
#include <stdio.h>
#define N 20
fun(char *tt,int num[])
{
int i,j;
int bb[10];
char *p=tt;
for(i=0;i<10;i++)
{
num[i]=0;
bb[i]=0;
}
/**********found**********/
while(①______)
{
if(*p>='0'&&*p<='9')
/**********found**********/ ②______;
p++;
} for(i=1,j=0;i<10;i=i+2,j++)
/**********found**********/ ③______;
}
main()
{
char str[N];
int num[10],k;
printf("\nPlease enter a string:");
gets(str);
printf("\n******** The original string ********\n");
puts(str);
fun(str,num);
printf("\n******** The number of letter ********\n");
for(k=0;k<5;k++)
{
printf("\n");
printf("%d=%d",2*k+1,num[k]);
}
printf("\n");
return;
}
/**********-code.c**********/答案
第1空:*p
第2空:bb[*p-'0']++
第3空:num[j]=bb[i]