当前位置:网站首页>每日一题——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=' ')
边栏推荐
- Debezium系列之:源码阅读之BinlogReader
- Time convolution Network + soft threshold + attention mechanism to realize residual life prediction of mechanical equipment
- Understand the session, cookie and token at one time, and the interview questions are all finalized
- LeetCode206. Reverse linked list [double pointer and recursion]
- Line test graph reasoning graph group class
- Revit secondary development - get the thickness / length / height of the beam
- The PHP source code of the new website + remove authorization / support burning goose instead of pumping
- Take full control! Create a "leading cockpit" for smart city construction
- Unity development --- the mouse controls the camera to move, rotate and zoom
- 行测-图形推理-8-图群类
猜你喜欢
Personal statement of testers from Shuangfei large factory: is education important for testers?
面试百问:如何测试App性能?
LeetCode142. Circular linked list II [two pointers, two methods for judging links in the linked list and finding ring points]
详解全志V853上的ARM A7和RISC-V E907之间的通信方式
Cause analysis and solution of too laggy page of [test interview questions]
微服務遠程Debug,Nocalhost + Rainbond微服務開發第二彈
How to judge whether the input content is "number"
Basic knowledge of binary tree
UWA Q & a collection
Understand the session, cookie and token at one time, and the interview questions are all finalized
随机推荐
关于海康ipc的几个参数
LeetCode206. Reverse linked list [double pointer and recursion]
UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xf9 in position 56: illegal multibyte sequence
Qt Graphicsview图形视图使用总结附流程图开发案例雏形
C # realizes the communication between Modbus protocol and PLC
Line test - graphic reasoning -7- different graphic classes
Cause analysis and solution of too laggy page of [test interview questions]
Sword finger offer 28 Symmetric binary tree
Amesim2016 and matlab2017b joint simulation environment construction
Robot autonomous exploration DSVP: code parsing
Gazebo import the mapping model created by blender
There is another problem just online... Warm
Aspose. Word operation word document (II)
Build an "immune" barrier in the cloud to prepare your data
XMIND mind mapping software sharing
De la famille debezium: SET ROLE statements supportant mysql8
不夸张地说,这是我见过最通俗易懂的,pytest入门基础教程
7-51 combination of two ordered linked list sequences
Online interview, how to better express yourself? In this way, the passing rate will be increased by 50%~
Microservice Remote debug, nocalhost + rainbond microservice Development second Bomb