陣列排序(冒泡,選擇,插入,希爾)

2021-05-22 01:02:23 字數 1365 閱讀 2573

package

org.owen;  

public

class

sortall ;  

system.out.println(

"----氣泡排序的結果:

");  

maopao(i);  

system.out.println();  

system.out.println(

"----選擇排序的結果:

");  

xuanze(i);  

system.out.println();  

system.out.println(

"----插入排序的結果:

");  

charu(i);  

system.out.println();  

system.out.println(

"----希爾(shell)排序的結果:

");  

shell(i);  

}  

//氣泡排序  

public

static

void

maopao(

int x)   

}  

}  

for(

inti : x)   

}  

//選擇排序  

public

static

void

xuanze(

int x)   

}  

//交換  

inttemp

=x[i];  

x[i]

=x[lowerindex];  

x[lowerindex]

=temp;  

}  

for(

inti : x)   

}  

//插入排序  

public

static

void

charu(

int x)   

}  

}  

for(

inti : x)   

}  

//希爾排序  

public

static

void

shell(

int x)

else

}  

x[j]

=temp;  

}  

}  

for(

inti : x)   

}  

}  

陣列排序總結(冒泡,選擇,插入,希爾)

package org.idcn.jse public class sortall system.out.println 氣泡排序的結果 maopao i system.out.println system.out.println 選擇排序的結果 xuanze i system.out.printl...

陣列排序總結(冒泡,選擇,插入,希爾)

1.package org.idcn.jse 2.3.public class sortall 12.system.out.println 氣泡排序的結果 13.maopao i 14.system.out.println 15.system.out.println 選擇排序的結果 16.xuanz...

冒泡 選擇 插入 希爾排序

include include include using namespace std template void print const t a,int n 氣泡排序 每次迴圈總是將最大元素移到隊尾 o n 2 穩定的排序演算法 templatevoid bubblesort t a,int n ...