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])
{
temp = T[d+1];
T[j+1]=T[j];
T[j]=temp;
}
}
return T;
}
}
並べ替え前 99 45 68 18 34 26 50 8 55 10並べ替え方法を確認するには、さらに進んでくださいJava 事前定義済み java.util.ArraysArrays.sort() および
並べ替え後 8 10 18 26 34 45 50 55 68 99
Please disable your ad blocker and refresh the window to use this website.