解题思路:
注意事项:
参考代码:
import java.util.Scanner;
import java.lang.*;
public class Main {
public static void main(String[] args) {
String[] s1 = new String[3];
defi(s1,3);
judge(s1, 3);
print(s1, 3);
}
public static void defi(String a[], int n) {
Scanner sc = new Scanner(System.in);
for (int i = 0; i < n; i++) {
a[i] = sc.next();
}
}
public static void judge(String s[], int n) {
for (int i = 0; i < 3; i++) {
for (int j = i; j < 3; j++) {
int tepm = s[i].compareToIgnoreCase(s[j]);
if (tepm > 0) {
String tepm1;
tepm1 = s[i];
s[i] = s[j];
s[j] = tepm1;
}
}
}
}
public static void print(String s[], int n) {
for (int i = 0; i < n; i++) {
System.out.println(s[i]);
}
}
}
0.0分
0 人评分