|
发表于 2018-3-7 11:12:56
|
显示全部楼层
- import java.util.Arrays;
- import java.util.Scanner;
- public class sort {
- public static void main(String[] args) {
- sort a = new sort();
- a.pi();
- }
-
- public void pi() {
- System.out.print("输入三个数字并以空格分隔:");
- Scanner input = new Scanner(System.in);
- String a = input.nextLine();
- String[] b = a.split(" ");
- int[] c = new int[3];
- for (int i = 0; i < b.length; i++) {
- c[i] = Integer.parseInt(b[i]);
- }
- Arrays.sort(c);
- for (int i = c.length-1; i > -1; i--) {
- System.out.print(c[i]+" ");
- }
- }
- }
复制代码 |
|