11. 读入两个整数
语法讲解
今天学: nextInt() 可以多次调用来读入多个整数。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a + b);
}
}
小练习
如果输入 3 5,输出是什么?
输入: 3 5
提交要求: 只提交最终输出结果,不要添加多余的说明或引号。
全部评论