public class tri_a_bulles_array{让我们看看这个程序是什么样子的:
public static void main(String[] args) {
int T[] = {99, 45, 68, 18, 34, 26, 50, 8, 55, 10};
System.out.print(排序前”);
for (int n:T)
System.out.print(n+ ”);
T = tri_a_bulles(T);
System.out.print(\n排序后”);
for (int n:T)
System.out.print(n+ ”);
}
static int[] tri_a_bulles(int T[])
{
int temp;
for(int i = T.length-1 ; i>=1 ; i--)
{
for(int j = 0 ; j<我;j++)
if(T[j] >T[d+1])
{
温度 = T[d+1];
T[j+1]=T[j];
T[j]=温度;
}
}
返回 T;
}
}
排序前 99 45 68 18 34 26 50 8 55 10您可以进一步查看排序方法Java 预定义java.util.Arrays它们是 Arrays.sort() 和
排序后 8 10 18 26 34 45 50 55 68 99
Please disable your ad blocker and refresh the window to use this website.