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