第十四組專案4 陣列的排序冒泡法

2021-06-19 13:07:33 字數 629 閱讀 9763

#include using namespace std;

void bubble_sort(int arr,int num);

void output_array(int arr,int num);//兩個函式的宣告

int main( )

; int b[15]= ;

bubble_sort(a,20); //用冒泡法按降序排序a 中元素

output_array(a,20);//輸出排序後的陣列 //函式的呼叫

bubble_sort(b,15); //用冒泡法按降序排序b 中元素

output_array(b,15);//輸出排序後的陣列

return 0;

}//請在下面定義bubble_sort 和output_array 函式

void bubble_sort(int arr,int num) //函式的定義

{ int i,j,t;

for(i=0; i

執行結果:

心得體會:

第十三周專案4 陣列的排序(冒泡法)

輸入描述 程式輸出 降序排列陣列的數並輸出 include using namespace std void bubble sort int a,int n void output array int a,int n int main int b 15 bubble sort a,20 用冒泡法按降...

第十四周 陣列的排序

檔名稱 完成日期 2013年 12月2日 版本號 v1.0 對任務及求解方法的描述部分 輸入描述 問題描述 程式輸出 問題分析 演算法設計 冒泡法 include using namespace std void bubble sort int arr,int num void output arr...

第十四周 選擇排序 氣泡排序打混編

01.01.01.02.02.02.程式的版權和版本宣告部分 05.05.05.檔名稱 array.cpp 06.06.06.作 者 07.07.07.完成日期 2013年 12 月 4 日 08.08.08.版本號 v1.0 09.09.09.輸入描述 無 10.10.10.問題描述 選擇排序 氣...