受益匪浅,坚持!
#include<iostream.h>
#include<string.h>
const int N=50;
void main()
{
char a[N];
cout<<"输入一个字符串:";
cin>>a;
int count[11]={0};
int n,i,j,k;
n=strlen(a);
k=0;
for(i=0;i<=9;i++)
{
for(j=0;j<n;j++)
{
if(a[j]-'0'==k)
count[i]++;
}
k++;
}
for(i=0;i<=9;i++)
cout<<"十进制数字字符是:"<<i<<"该字符的个数是: "<<count[i]<<endl;
}