1

看板ck60th311作者 (火海小英雄)時間14年前 (2009/11/19 19:56), 編輯推噓4(401)
留言5則, 4人參與, 最新討論串1/1
#include <iostream> #define ELEMENTS 10 using namespace std; void insertion_sort(char x[],int length) { int key,i; for(int j=1;j<length;j++) { key=x[j]; i=j-1; while(x[i]>key && i>=0) { x[i+1]=x[i]; i--; } x[i+1]=key; } } int main() { char A[ELEMENTS]={'G','F','V','T','K','J','L','M','N','B'}; int x; cout<<"NON SORTED LIST:"<<endl; for(x=0;x<ELEMENTS;x++) { cout<<A[x]<<endl; } insertion_sort(A,ELEMENTS); cout<<endl<<"SORTED LIST"<<endl; for(x=0;x<ELEMENTS;x++) { cout<<A[x]<<endl; } return 0; } 界貼 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.119.17.167

11/19 20:08, , 1F
我現在得了看了程式碼會嘔吐的病....
11/19 20:08, 1F

11/19 22:53, , 2F
這麼簡單的程式,也敢拿出來炫耀
11/19 22:53, 2F

11/19 23:19, , 3F
說時在的這些我全部都看不懂 完全沒念茲夠
11/19 23:19, 3F

11/21 17:42, , 4F
阿巧什麼都會,最強了
11/21 17:42, 4F

11/21 17:47, , 5F
哪有你強
11/21 17:47, 5F
文章代碼(AID): #1B1J9kRm (ck60th311)