解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int num1 = scanner.nextInt(); int num2 = scanner.nextInt(); char char1 = scanner.next().charAt(0); //字符char的输入方法 char char2 = scanner.next().charAt(0); String str1 = scanner.next(); String str2 = scanner.next(); System.out.println(Compare(num1, num2)); System.out.println(Compare(char1, char2)); System.out.println(Compare(str1, str2)); } public static int Compare(int a, int b) { //函数重载 if (a > b) { return a; } else { return b; } } public static int Compare(char a, char b) { return Math.abs((int) a - (int) b); } public static String Compare(String a, String b) { if (a.compareTo(b) > 0) { return a; } else { return b; } } }
0.0分
2 人评分
【蟠桃记】 (C语言代码)浏览:711 |
Pascal三角 (C语言代码)浏览:1252 |
WU-格式化数据输出 (C语言代码)浏览:1818 |
printf基础练习2 (C语言代码)浏览:690 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:1483 |
数字游戏 (C++代码)浏览:1240 |
1051(奇了怪了)浏览:747 |
Quadratic Equation (C语言代码)浏览:1034 |
交换Easy (C语言代码)浏览:805 |
敲七 (C++代码)浏览:1119 |