对10个数进行排序。
import java.util.*;
public class test7{
public static void main(String[] args) {
Scanner s = new Scanner( 【4】 );
int[] a = new int[10];
System.out.println("请输入10个整数:");
for(int i=0; i<10; i++) {
a[i] = s. 【5】 ;
}
for(int i=0; i<10; i++) {
for(int j=i+1; j<10; j++) {
if(a[i] > a[j]) {
int t = a[i];
【6】
a[j] = t;
}
}
}
for(int i=0; i<10; i++) {
System.out.print(a[i] + " ");
}
}
}
System.in
nextInt()
a[i] = a[j];
import java.util.*;
public class test7 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int[] a = new int[10];
System.out.println("请输入10个整数:");
for (int i = 0; i < 10; i++) {
a[i] = s.nextInt();
}
for (int i = 0; i < 10; i++) {
for (int j = i + 1; j < 10; j++) {
if (a[i] > a[j]) {
int t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
for (int i = 0; i < 10; i++) {
System.out.print(a[i] + " ");
}
}
}