L1-003 个位数统计 (15 分)

版权声明:SupremeBeast3_ https://blog.csdn.net/weixin_43359312/article/details/89055646

L1-003 个位数统计 (15 分)

在这里插入图片描述
输入样例:
100311
输出样例:
0:2
1:3
3:1

AC代码

#include <iostream>
#include <cstdio>
using namespace std;
int main() {
	char ch;
	int Digit[11] = { 0 };
	while ((ch = getchar()) != '\n') Digit[ch - '0']++;
	for (int i = 0; i < 10; i++) if (Digit[i] != 0) printf("%d:%d\n", i, Digit[i]);
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43359312/article/details/89055646