首页 > 试题广场 >

多组_A+B_T组形式

[编程题]多组_A+B_T组形式
  • 热度指数:17685 时间限制:C/C++ 3秒,其他语言6秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解
给定 t 组测试数据。
每组数据有两个整数 ab ,请你求出 a+b 的值。

输入描述:
第一行有一个整数 t\ (\ 1 \leq t \leq 10^5\ )
每行有两个整数 a\ (\ 1 \leq a \leq 10^9\ )b\ (\ 1 \leq b \leq 10^9\ )


输出描述:
输出 t 行,每行一个整数,代表 a+b 的值。
示例1

输入

3
1 2
114 514
2024 727

输出

3
628
2751
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
   
        // 注意 hasNext 和 hasNextLine 的区别
             int c = in.nextInt();
             for(int e=0;e<c;e++){
             int a = in.nextInt();
             int b = in.nextInt();
            System.out.println(a + b);
        }
    }
}
发表于 2025-05-20 11:10:48 回复(0)
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int t = input.nextInt();
        for(int i = 0; i < t; i++) {
            int a = input.nextInt();
            int b = input.nextInt();
            System.out.println(a+b);
        }
    }
}

发表于 2025-03-08 16:31:40 回复(0)
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        while (count-->0) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            System.out.println(a + b);
        }
    }
}
发表于 2024-10-30 15:53:47 回复(0)
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        in.nextInt();//将第一行的数据提前取出来了是可以,但觉得很奇怪
        while (in.hasNextInt()) {
            int a = in.nextInt();
            int b = in.nextInt();
            System.out.println(a + b);
        }
    }
}
发表于 2024-09-25 11:12:55 回复(0)