我是靠谱客的博主 无辜鱼,这篇文章主要介绍3.10 PAT1024 乙级 python(第四个测试点错误 等后期修改),现在分享给大家,希望可以做个参考。

科学计数法

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
x = list(input()) result = '' eindex = 0 daxiao = 0 pindex = 0 nindex = 0 endnindex = 0 for i in range(len(x)): if x[i].isdigit() and eindex == 0 : nindex = i elif x[i] =='.': pindex = i elif x[i] == 'E': eindex = i elif x[i].isdigit() and eindex != 0 and endnindex == 0: endnindex = i elif (x[i] == '+' or x[i] == '-') and eindex != 0: if x[i] == '+': daxiao = 1 zhishu = int(''.join(x[endnindex:len(x)])) if x[0] == '-': result = result + '-' if zhishu ==0: result += ''.join(x[1:nindex+1]) else: if daxiao == 1: if nindex-2>int(x[-2:-1][0]+x[-1]): result = result+x[1]+ ''.join(x[3:zhishu+3])+'.'+''.join(x[zhishu+1:nindex+1]) else: result = result+x[1]+''.join(x[3:nindex+1])+'0'*(zhishu-(nindex-2)) else: result = result+'0.'+(zhishu-1)*'0'+x[1]+''.join(x[3:nindex+1]) print(result)

 

最后

以上就是无辜鱼最近收集整理的关于3.10 PAT1024 乙级 python(第四个测试点错误 等后期修改)的全部内容,更多相关3.10内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(64)

评论列表共有 0 条评论

立即
投稿
返回
顶部