1118: Tom数(python) 摘要:解题思路:注意事项:补充大佬解法,要加上except EOFError才能运行通过参考代码:while True: try: print(sum([int(i) for i in …… 题解列表 2023年01月20日 0 点赞 0 评论 355 浏览 评分:9.9
题目 1118: Tom数【两行代码】 摘要:解题思路:[int(i) for i in input()] :将输入的数字字符串转换为列表,其实就是迭代的过程sum() :对列表内的数据进行求和注意事项:无参考代码:while True: …… 题解列表 2022年05月06日 0 点赞 0 评论 897 浏览 评分:9.9
1118: Tom数(python) 摘要:解题思路:注意事项:参考代码:while(True): a=input() sum=0 for i in a: sum+=int(i) print(sum)…… 题解列表 2022年02月05日 0 点赞 0 评论 562 浏览 评分:9.9
Tom数-题解(Python代码) 摘要:python input的返回值是字符串,故直接求和即可。 ```python x=input() while x: print(sum([int(i) for i in x])) …… 题解列表 2019年09月07日 0 点赞 0 评论 1620 浏览 评分:9.2
TOM数:思路及其简单,但是有个小坑 摘要:解题思路:遍历每一个输入,然后将每一位累加就可以了,这题主要是测试样例跟你玩脑筋急转弯注意事项:有一个测试样例第一位就是EOF,不知道是不是网站系统更新了,之前通过的老代码现在重新用反而通过不了了,就…… 题解列表 2023年09月30日 0 点赞 0 评论 360 浏览 评分:9.0
Tom数-题解(Python代码) 摘要:###Python 一行解决 ``eval() 函数可以用于计算字符串表达式的值`` `例如:eval("2*2") ==4 True ` 上代码 ```python try: …… 题解列表 2020年02月25日 0 点赞 0 评论 807 浏览 评分:6.0
几行代码解决||python 摘要:解题思路:输入的皆为字符串,那么字符串的每个字符是可以得到,将其转为int类型再相加即可。注意事项:参考代码:while True: m = input() l = 0 for i …… 题解列表 2021年03月02日 0 点赞 0 评论 505 浏览 评分:6.0
python用map函数只需要三行 摘要:解题思路: 输入数据 处理数据: 用map函数处理字符串,在python3中map函数是返回的迭代器,所以使用list(map())可以将字符串处理成…… 题解列表 2021年04月11日 0 点赞 0 评论 410 浏览 评分:6.0
1118: Tom数-题解(python) 摘要:解题思路:注意事项:参考代码:while True: a = input() l = [] for i in a: l.append(int(i)) m = su…… 题解列表 2021年10月19日 0 点赞 0 评论 154 浏览 评分:0.0
编写题解 1118: Tom数 摘要:解题思路:注意事项:参考代码:while True: try: print(sum(list(map(int, input())))) except: …… 题解列表 2024年04月10日 0 点赞 0 评论 307 浏览 评分:0.0