Calculate the Sum of Integers in Python
算法思路:
对于每组输入的整数,我们可以通过循环遍历的方式求出它们的和,并将和输出即可。
Python3 代码:
N = int(input())
for i in range(N):
M = int(input())
nums = list(map(int, input().split()))
sum = 0
for num in nums:
sum += num
print(sum)
原文地址: https://www.cveoy.top/t/topic/oMqN 著作权归作者所有。请勿转载和采集!