1 package FushiExam;
2 import java.util.*;
3 public class Text_28 {
4
5 public static void main(String[] args) {
6 // 对10个数进行排序(冒泡排序)
7 Scanner scan=new Scanner(System.in);
8 int [] arr=new int[10];
9 for(int k=0;k<10;k++) {
10 arr[k]=scan.nextInt();
11 }
12 for(int i=arr.length-1;i>0;i--) {
13 for(int j=0;j
14 if(arr[j]>arr[j+1])
15 swap(arr,j,j+1);
16 }
17 }
18 System.out.println("排序后结果:");
19 for(int m=0;m
20 System.out.print(" "+arr[m]);
21 }
22 }
23 public static void swap(int arr[],int i,int j) {//交换数组在数组中交换才可以实现
24 int t=arr[i];
25 arr[i]=arr[j];
26 arr[j]=t;
27 }
28
29 }
标签:10,arr,JAVA,int,System,冒泡排序,排序
来源: https://www.cnblogs.com/fmust/p/12508759.html