首页 > 试题广场 >

多组数据a+b III

[编程题]多组数据a+b III
  • 热度指数:19564 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解
\hspace{15pt}计算多组测试用例中两个整数 a,b 的和。当输入的两个整数均为 0 时,表示输入结束,不再处理该组。

输入描述:
\hspace{15pt}多组测试用例,每行输入两个整数 a,b0 \leqq a,b \leqq 1000),用空格隔开。当且仅当 a=0b=0 时,输入结束,该组数据不处理。


输出描述:
\hspace{15pt}对于每组测试用例 a,b,输出一个整数,表示 a+b 的结果,每个结果占一行。
示例1

输入

1 1
2 2
0 0

输出

2
4

说明

第一组:1+1=2;第二组:2+2=4;遇到 0\ 0 后结束,不处理。
while True:
    a,b = map(int,input().split())
    if a==0 and b==0:
        break
    elif 0<a<=1000 and 0<b<=1000:
        print(a+b)

发表于 2025-12-17 22:03:58 回复(0)
import sys
lines = sys.stdin.read().splitlines()
for line in lines:
    nums = list(map(int, line.split()))
    if sum(nums) != 0:
        print(sum(nums))
    else:
        sys.exit()

发表于 2025-10-31 10:31:51 回复(0)
while 1:
    a,b=map(int,input().split())
    p=a==b==0
    if p:break
    print(a+b)

发表于 2025-10-28 10:49:21 回复(0)
while True:
    a,b=map(int,input().split())
    if a==0 and b==0:
        break
    print(a+b)
发表于 2025-09-28 23:33:16 回复(0)
while True:
    a,b=map(int,input().split())
    if a!=0 or b!=0:
        print(int(a+b))
    else:
        break

发表于 2025-09-15 21:18:28 回复(0)
n=int(input())
for i in range(n):
    s=input().split()
    a,b=int(s[0]),int(s[1])
    if a==b==0:
        break
    else:
        print(a+b)
发表于 2025-08-04 15:57:56 回复(0)