wangting
2024-12-26 fa261e8c1220b31af54e8167e4de9c3320b1af27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.vci.client.framework.specialrole;
 
import java.util.Scanner;
 
public class Test {
 
    /**
     * 排序
     * @param str
     */
    public void compareMaxMin(int str[]){
        int temp;
        for(int i=0;i<str.length;i++){
            for(int j=i+1;j<str.length;j++){
                if(str[i]>str[j]){
                    temp=str[i];
                    str[i]=str[j];
                    str[j]=temp;
                }
            }
        }
        for(int k=0;k<str.length;k++){
            System.out.println(str[k]+"");
        }
    }
 
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        System.out.println("输入第一个数:");
        int a = sc.nextInt();
        System.out.println("输入第二个数:");
        int b = sc.nextInt();
        System.out.println("输入第三个数:");
        int c = sc.nextInt();
        System.out.println("输入第四个数:");
        int d = sc.nextInt();
        int[] str = {a,b,c,d};
        Test t = new Test();
        t.compareMaxMin(str);
    }
}