1021 个位数统计 (15分)

#include <iostream>
#include <string.h>

using namespace std;

int main()
{
    char n[1002];
    int num[11];
    int c[11]={0};
    int tmp;
    cin>>n;
    for(int i=0;i<=9;i++)
        num[i]=i;
    for(int i=0;i<strlen(n);i++)
    {
        tmp=n[i]-48;
        c[tmp]++;
    }
    for(int i=0;i<=9;i++)
        if(c[i]!=0)
            cout<<i<<":"<<c[i]<<endl;
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/QRain/p/12228821.html
今日推荐