每组数据有两个整数
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (true) { int a = scanner.nextInt(); int b = scanner.nextInt(); if (a == 0 && b == 0) { break; } System.out.println(a + b); } scanner.close(); } }
#include <stdio.h> int main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF) { if(a==0||b==0) break; printf("%d\n",a+b); } }
use std::io::{self, *}; fn main() { let Stdin = io::stdin(); while let Some(Ok(line)) = Stdin.lock().lines().next() { let inputs = line.split(" ").collect::<Vec<_>>(); let a = inputs[0].parse::<i32>().unwrap(); let b = inputs[1].parse::<i32>().unwrap(); if a == 0 && b == 0 { break; } println!("{}", a+b); } }
public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 while (in.hasNextInt()) { // 注意 while 处理多个 case int a = in.nextInt(); int b = in.nextInt(); if(a==b&a==0){ continue; }else{ System.out.println(a + b); } } } }