37. 比较两数
语法讲解
今天学: 用 if-else 可以比较两个数的大小。
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();
if (a > b) {
System.out.println(a);
} else {
System.out.println(b);
}
}
}
小练习
输入 8 15,输出是什么?
输入: 8 15
提交要求: 只提交最终输出结果,不要添加多余的说明或引号。
全部评论