个位数统计

题源

团体程序设计天梯赛

题解

#include<iostream>
using namespace std;
char c;
int box[10]={0};
int main(){
    for(;scanf("%c",&c)!=EOF;)box[c-'0']++;
    for(int i=0;i<10;i++){
        if(box[i]!=0){
            cout << i << ":" << box[i] << endl;
        }
    }
    return 0;
}
posted @ 2021-04-22 22:06  summeriver13  阅读(18)  评论(0)    收藏  举报