5
8 3 6 4 9
3 4 6 8 9
package data;
import java.util.Scanner;
public class Data721 {
//冒泡排序
public static void main(String[] args)
{
int n;
Scanner cin = new Scanner(System.in);
n = cin.nextInt();
Integer[] f = new Integer[n+1];
int i;
for (i = 0; i < n; i++) {
f[i] = cin.nextInt();
}
int k,j;
for (i = 0;i<n;i++)
{
for(j= i+1;j<n;j++)
{
if(f[i]>f[j])
{
k = f[i];
f[i] = f[j];
f[j] = k;
}
}
}
for(i = 0;i<n;i++)
{
System.out.print(f[i] + " ");
}
}
}
原文:https://www.cnblogs.com/tmtboke/p/15039317.html