个位数统计

我的代码:

#include<iostream>
#include<cstring>
using namespace std;
int x[10];
int main()
{
char *y=new char[1000];
cin>>y;
int i=0;
while(y[i]!=0)
{
x[y[i]-48]++;
i++;
};
i=0;
for(;i<10;i++)
if(x[i]!=0)
cout<<i<<":"<<x[i]<<endl;
return 0;
}

posted @ 2019-10-21 17:52  大千世界没  阅读(141)  评论(0)    收藏  举报