[轉錄][情報] BBS 程式碼標色小工具

看板HKday作者 (澳門遊行1220)時間16年前 (2007/12/19 20:22), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
※ [本文轉錄自 EZsoft 看板] 作者: LiloHuang (築夢踏實) 看板: EZsoft 標題: [情報] BBS 程式碼標色小工具 時間: Sun Jun 10 22:51:30 2007 可針對 C, Java, PHP, Perl , Python, Bash, SQL, HTML, XML, CSS, Javascript 等... 程式碼做標色動作, 我則修改自Google Code Prettifier的版本, 改良為BBS標色工具 PS. 轉換後直接全選複製, 彩色貼上到BBS畫面即可 ( 注意, 這個工具不會自動修改寬度 ) http://blog.roodo.com/kenwu/archives/3444993.html 效果: [ 以非遞迴快速排序法為例 ] #include<iostream> #include<cstdlib> #include<stack> using namespace std; typedef struct stack_node *ptr; // 定義一個結構 裡面有low/high typedef struct stack_node { int low; int high; }; stack<ptr> s; // 定義一個堆疊, 使用上面結構 void quicksort(int list[],int first,int last) { ptr entry = new stack_node; entry->low = first; entry->high = last; s.push(entry); // 產生一個新節點 紀錄邊界值 while( !s.empty() ) // 當堆疊非空, 進行切割征服 { ptr temp = s.top(); // 取出堆疊頂端 s.pop(); // pop刪除堆疊頂端 if(temp->low < temp->high) // 如果要排的資料陣列位置正確 { int key = list[temp->low]; int left = temp->low; int right = temp->high+1; do { do left++; while(list[left]<key); do right--; while(list[right]>key); if(left<right) { swap(list[left],list[right]); } } while (left<right); swap(list[temp->low],list[right]); // 與中間值交換 ptr leftrec = new stack_node; // 產生模擬左遞迴的堆疊節點 leftrec->low = temp->low; leftrec->high = right-1; ptr rightrec = new stack_node; // 產生模擬右遞迴的堆疊節點 rightrec->low = right+1; rightrec->high = temp->high; s.push(leftrec); // 分別加入堆疊中模擬 s.push(rightrec); } } } int main(void) { int list[]={5,4,2,12,6,13,10,20,8,2}; int size=sizeof(list)/sizeof(*list)-1; quicksort(list,0,size); for(int k=1;k<=size;k++) cout<<list[k]<<endl; system("PAUSE"); return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.127.71.200 LiloHuang:轉錄至看板 share 06/10 22:58

06/10 22:58,
還蠻酷的
06/10 22:58

06/10 22:59,
X....太帥了
06/10 22:59

06/10 23:00,
大推
06/10 23:00

06/10 23:03,
L大~ 大推
06/10 23:03

06/10 23:03,
可是好像不支援fx??
06/10 23:03

06/10 23:07,
複製的功能不能支援 要自己Ctrl+A全選複製唷^^"
06/10 23:07

06/10 23:21,
PUSH
06/10 23:21

06/11 00:37,
好酷阿
06/11 00:37

06/11 08:07,
cool!
06/11 08:07

06/11 10:25,
推推推
06/11 10:25

06/11 10:32,
推~~~~~~~~
06/11 10:32

06/11 13:29,
推一個 酷~
06/11 13:29

06/11 13:29,
為甚麼last也被標色?
06/11 13:29

06/11 14:17,
last是Perl語法...我會再新增可以選擇要哪種語言
06/11 14:17

06/11 16:23,
可以轉到程式版嗎?
06/11 16:23

06/11 16:23,
原po自己寫的程式?
06/11 16:23

06/11 19:00,
sure:)
06/11 19:00
-- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.100.180.172
文章代碼(AID): #17QGqSXk (HKday)