当前位置:网站首页>每日一题——PAT乙级1002题
每日一题——PAT乙级1002题
2022-07-07 21:49:00 【InfoQ】
一、PAT (Basic Level) Practice (中文)第1002题
输入格式:
输出格式:
输入样例:
1234567890987654321123456789
输出样例:
yi san wu
transform={'1':'yi','2':'er','3':'san','4':'si','5':'wu','6':'liu','7':'qi','8':'ba','9':'jiu','0':'ling'}
#输入
a=input()
#将输入的数字字符串转换为列表的形式
b=list(a)
#将数字中的每一位求和
c=sum(int(i) for i in b)
#求和结果转为字符串形式,用于计算长度
d=str(c)
#标记位,用来判断for循环的最后一个
flag=0
for j in d:
flag=flag+1
#如果为for循环的最后一位,则不输出空格
if flag==len(d):
#print默认的end为end='\n',先根据情况将其修改
print(transform[j],end='')
else:
print(transform[j],end=' ')
transform={'1':'yi','2':'er','3':'san','4':'si','5':'wu','6':'liu','7':'qi','8':'ba','9':'jiu','0':'ling'}
a=input()
print("input输入的类型:",type(a))
b=list(a)
print("转发化为列表的b为:",b)
#c=sum(int(i) for i in b)
sum=0
for i in a:
s=int(i)
sum=sum+s
print('sum的数据类型:',type(sum)," 结果: ",sum)
d=str(sum)
print("转化为字符串形式的sum"," 类型:",type(d)," 字符串形式的数:",d," 他的长度:",len(d))
flag=0
for j in d:
flag=flag+1
if flag==len(d):
print(transform[j],end='')
else:
print(transform[j],end=' ')
边栏推荐
- Digital transformation: five steps to promote enterprise progress
- Debezium系列之:源码阅读之SnapshotReader
- Redis cluster installation
- Quick sort (diagram +c code)
- 苹果在iOS 16中通过'虚拟卡'安全功能进一步进军金融领域
- Unity local coordinates and world coordinates
- Visual design form QT designer design gui single form program
- IP network active evaluation system -- x-vision
- 行测-图形推理-8-图群类
- Yarn cannot view the historical task log of yarn after enabling ACL user authentication. Solution
猜你喜欢

数字化转型:五个步骤推动企业进步

行测-图形推理-3-对称图形类

Matplotlib quick start

PHP method of obtaining image information

Microbial Health Network, How to restore Microbial Communities

详解全志V853上的ARM A7和RISC-V E907之间的通信方式

行测-图形推理-7-相异图形类

GBU1510-ASEMI电源专用15A整流桥GBU1510

肠道里的微生物和皮肤上的一样吗?

Early childhood education industry of "screwing bar": trillion market, difficult to be a giant
随机推荐
Leetcode1984. Minimum difference in student scores
The PHP source code of the new website + remove authorization / support burning goose instead of pumping
Form组件常用校验规则-2(持续更新中~)
关于海康ipc的几个参数
php 记录完整对接腾讯云直播以及im直播群聊 所遇到的坑
Ligne - raisonnement graphique - 4 - classe de lettres
UWA Q & a collection
Build an "immune" barrier in the cloud to prepare your data
微生物健康网,如何恢复微生物群落
What is fake sharing after filling the previous hole?
Amesim2016 and matlab2017b joint simulation environment construction
ASP. Net core introduction V
微生物健康網,如何恢複微生物群落
This time, let's clear up: synchronous, asynchronous, blocking, non blocking
苹果在iOS 16中通过'虚拟卡'安全功能进一步进军金融领域
How pyGame rotates pictures
Pyqt GUI interface and logic separation
行测-图形推理-2-黑白格类
IP network active evaluation system -- x-vision
Nx10.0 installation tutorial