AC代码
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
const int max_n = 1010;
char ans[max_n];
int count[10][2] = {0};
int main() {
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE
char a;
int times = 0;
//gets()在PAT编译里面错误,故换了种方法读入数据
while(cin >> a) {
ans[times++] = a;
}
int length = strlen(ans);
for(int i = 0; i < length; i++) {
int a = ans[i] - '0';
count[a][1] = 1;
count[a][0]++;
//printf("count[%d][1]: %d, count[ans[%d]][0]:%d\n", a, count[a][1], a, count[a][0]);
}
for(int i = 0; i < 10; i++) {
if(count[i][1] == 1) {
printf("%d:%d\n", i, count[i][0]);
}
}
return 0;
}