PAT (Basic Level) Practice (中文)1021 个位数统计 python

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

代码:

n = input()

num = [0] * 10  #建立一个数组,用来统计0-9出现的次数

for i in n:
    num[int(i)] += 1

for i in range(10):
    if num[i] != 0:
        print('%d:%d'%(i,num[i]))   #按格式输出

猜你喜欢

转载自blog.csdn.net/qq_44672855/article/details/117028503
今日推荐