python3求助

P2393 yyy loves Maths II

6 你c++写多了吧
by lazy_doghead @ 2023-01-27 20:20:58


@[denghuolanshanchu](/user/893114) 输入不一定是整数,所以要用float
by shiyiheng @ 2023-01-27 20:34:50


@[denghuolanshanchu](/user/893114) except后面要print('0.00000')不然会输出0.0
by shiyiheng @ 2023-01-27 20:37:28


@[denghuolanshanchu](/user/893114) 剩下不会改了~~于是借来了某位大佬的代码~~ ```python try: a = list(map(float,input().split())) ans = 0 for i in a: ans += i print('{:.5f}'.format(ans)) except: print('0.00000') ```
by shiyiheng @ 2023-01-27 20:40:05


@[denghuolanshanchu](/user/893114) 搞错了,是这个 ```python from decimal import Decimal try: nums=input().split() s=0 for i in nums: s+=Decimal(i) print('{:.5f}'.format(s)) except: print('0.00000') ```
by shiyiheng @ 2023-01-27 20:41:04



by denghuolanshan_1024 @ 2023-01-28 10:52:51


@[lazy_doghead](/user/746229) 我没学过C艹啊
by denghuolanshan_1024 @ 2023-01-28 10:53:22


|