我们可以使用while循环来计算1加到n的求和: n = int(input("请输入一个整数:")) sum = 0 i = 1 while i <= n: sum += i i += 1 print("1到{}的求和为:{}".format(n, ...
確定! 回上一頁