解题思路:
- 用字符串存储 < 1000 的整数
- 用一个整数数组存储 0-9 出现的次数
#include <stdio.h>
#include <string.h>
#define N1 1001
#define N2 10
int a[N2] = {0};
char n[N1];
int main()
{
scanf("%s", n);
int len = strlen(n);
for (int i = 0; i < len; i++)
a[n[i]-'0']++;
for (int i = 0; i < N2; i++)
if (a[i] != 0)
printf("%d:%d\n", i, a[i]);
return 0;
}