Task Description
泡沫排序法(指標)
撰寫氣泡排序法將陣列排序
Hint
bubble.h
打上 function header 以及相關的設定。void bubble(int *arr);
bubble.c
撰寫程式碼後對應上傳。#include "bubble.h"void bubble(int *arr){ // add your code}
main.c
這個檔案無法更改也無須上傳。12345678910111213 #include <stdio.h>#include "bubble.h" int main(){ int arr[5]; int i; for( i=0 ; i<5 ; i++) { scanf("%d",&arr[i]); } bubble(arr);}
Input Format
測試資料為五個整數。
Output Format
請撰寫一函示使程式按照順序排列。
Sample Input
1 3 5 1 4 2
Sample Output
1 1 2 3 4 5