2261: 重载--求两数较大值
金币值:2
定数:6
时间限制:1.000 s
内存限制:128 M
解决:0
提交:0
正确率:0.00% 命题人:
题目描述
编写程序求两个数的较大值,要求通过重载max()方法(两个)完成相应功能。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
String s1, s2;
int x, y;
Scanner in = new Scanner(System.in);
s1 = in.nextLine();
s2 = in.nextLine();
x = in.nextInt();
y = in.nextInt();
System.out.println("the larger value is:" + Tool.max(s1, s2));
System.out.println("the larger value is:" + Tool.max(x, y));
}
}
/* 以下为你的代码 */ 输入
共4行:
1、2行是2个字符串
3、4行是2个整数
1、2行是2个字符串
3、4行是2个整数
输出
见样例
样例输入 复制
java
abc
121
232
样例输出 复制
the larger value is:java
the larger value is:232