关于统计字符个数
输入一个大于十位正整数,统计出各数字字符的个数
程序代码:
#include<stdio.h> #include<stdlib.h> int main() { int num[10],i; char ch; memset(num,0,sizeof(num)); while((ch=getchar())!='\n') num[ch-'0']++; for(i=0;i<10;i++) printf("%d=%d ",i,num[i]); return 0; }
562158654215937217895462582846219854675295798169749832657302789426157032593
0=2 1=6 2=11 3=5 4=6 5=12 6=8 7=8 8=8 9=9
--------------------------------
Process exited after 6.172 seconds with return value 0
请按任意键继续. . .
0=2 1=6 2=11 3=5 4=6 5=12 6=8 7=8 8=8 9=9
--------------------------------
Process exited after 6.172 seconds with return value 0
请按任意键继续. . .