首页 > 试题广场 >

多组数据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 后结束,不处理。
头像 牛客牛我不牛
发表于 2021-12-15 21:03:15
#include<stdio.h> #include <stdlib.h> int main() { int a,b,c; do{ scanf("%d%d",&a,&b); c=a+b; if(c!=0) 展开全文
头像 Aju要上广大
发表于 2023-02-04 16:40:37
#include using namespace std; int main() { int a,b,c; while(cin>>a>>b) { if(a==0&&b==0) break; c=a+b; cout<<c&l 展开全文
头像 完美的小黄鸭追赶太阳
发表于 2025-05-30 21:41:51
import sys for line in sys.stdin: a, b = map(int,line.split()) if a == b == 0: break else: print(a+b)
头像 小违心
发表于 2024-04-01 20:05:18
#include using namespace std; int main(){ int i,a,b; while( scanf("%d %d",&a,&b)){ if(a!=0&&b!=0) printf("%d\n",a+b); 展开全文
头像 CARLJOSEPHLEE
发表于 2025-07-16 19:25:02
放弃了,好像写不出一行 while 1: a,b = map(int,input().split()) if a == b == 0: exit() print(a+b)
头像 positive_ll
发表于 2025-06-17 14:29:25
a,b=list(map(int,input().split())) while(a!=0 or b!=0): print(a+b) a,b=list(map(int,input().split()))
头像 Codecodify
发表于 2023-05-04 09:01:36
#include <stdio.h> int main() { int a, b; while(scanf("%d%d", &a, &b) != EOF) { if(a == 0 && b == 0) { 展开全文
头像 易烊千玺圈外女友
发表于 2021-08-02 15:53:41
#include <stdio.h> #include <math.h> int main() { int m,n,i; while ( scanf("%d %d",&m,&n) !=EOF) { 展开全文
头像 165男生的逆袭
发表于 2025-10-13 08:47:50
#include <stdio.h> #include <stdlib.h> #define MAX_SIZE 1000 int main() { int a, b; int* results = (int*)malloc(MAX_SIZE * sizeo 展开全文
头像 奔放的小鲸鱼许愿ssp
发表于 2025-07-14 18:00:17
#include <stdio.h> int main() { while(1) { int a,b; scanf("%d%d",&a,&b); if(a==0&&b== 展开全文