多组测试用例,每行输入两个整数 (),用空格隔开。当且仅当 且 时,输入结束,该组数据不处理。
对于每组测试用例 ,输出一个整数,表示 的结果,每个结果占一行。
1 1 2 2 0 0
2 4
第一组:;第二组:;遇到 后结束,不处理。
while 1: a,b=map(int,input().split()) p=a==b==0 if p:break print(a+b)
#include <iostream> using namespace std; int main() { int a,b; while(cin >> a >> b && a != 0 && b != 0){ cout << a+b << endl; } }
t = True while t: a, b = map(int, input().split()) if a == 0 and b == 0: t = False else: print(a + b)
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()
#include <iostream> using namespace std; int main() { int a,b; while(cin>>a>>b&&a!=0&&b!=0){ cout<<a+b<<endl; } }
#include <stdio.h> int main() { int a, b; for(;;){ scanf("%d %d\n", &a, &b); if(a==0 && b==0) break; printf("%d\n", a + b); } return 0; }
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题