C题解 1021 个位数统计 (15 分)


原题

https://pintia.cn/problem-sets/994805260223102976/problems/994805300404535296

代码

#include 
using namespace std;

int result[10]={0};//存储0-9出现的次数
int main()
{
    char c;
    while (c != '\n')
    {
        scanf("%c", &c);//单个字符读取
        if (c >= '0' && c <= '9')
        {          
            result[c -'0']++;
        }
        
    }

    for (int i = 0; i < 10; i++)
    {
        if (result[i]>0)
        {
            cout <