PAT字符串处理题---1021 个位数统计 (15分)

1021 个位数统计 (15分)

#include<iostream>
#include<string>
#include<cstdio>


using namespace std;


int main(){
	string s;cin>>s;
	int a[1005]={0};
	for(int i=0;i<s.length();i++){
		a[s[i]-'0']++;
	}
	for(int i=0;i<=9;i++){
		if(a[i]) cout<<i<<":"<<a[i]<<"\n";
	}
	return 0;
}
posted @ 2020-06-09 17:59  chstor  阅读(98)  评论(0)    收藏  举报