填空题
请补充main()函数,该函数的功能是:从字符串str中取出所有数字字符,并分别计数,然后把结果保存在数组tt中并输出,把其他字符保存在tt[10]中。
例如,当str1=“00237481367539dfji”时,结果为
0:21:12:13:34:15:16:17:28:19:1
other charactor:4
注意:部分源程序给出如下。
请勿改动main()函数和其他函数中的任何内容,仅在横线上填入所编写的若干表达式或语句。
试题程序:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
void main()
int i,tt[11];
char*str="00237481367539dfji";
char*p=str;
syslem("CLS");
printf("***the origial data***/n");
puts(str);
for(i=0;i<11;i++)
tt[i]=0;
while(*p)
{
switch(
1)
{
case"0":tt[0]++;break;
case"1";tt[1]++;break;
case"2":tt[2]++;break;
case"3":tt[3]++;break;
case"4":tt[4]++;break;
case"5":tt[5]++;break;
case"6":tt[6]++;break;
case"7":tt[7]++;break;
case"8":tt[8]++;break;
case"9":tt[9]++;break;
2
}
3
}
printf("****the result****/n");
for(i=0;i<10;i++)
printf("/n%d:%d",i,tt[i]);
printf("/nother charactor:%d",tt[i]);
}