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

看板EZsoft作者 (築夢踏實)時間17年前 (2007/06/10 22:51), 編輯推噓16(1601)
留言17則, 14人參與, 最新討論串1/2 (看更多)
可針對 C, Java, PHP, Perl , Python, Bash, SQL, HTML, XML, CSS, Javascript 等... 程式碼做標色動作, 我則修改自Google Code Prettifier的版本, 改良為BBS標色工具 PS. 轉換後直接全選複製, 彩色貼上到BBS畫面即可 ( 注意, 這個工具不會自動修改寬度 ) http://wish.kuso.cc/bbscode.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, , 1F
還蠻酷的
06/10 22:58, 1F

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

06/11 19:00, , 17F
sure:)
06/11 19:00, 17F
macau1220:轉錄至看板 HKday 12/19 20:22 ※ 編輯: LiloHuang 來自: 211.79.63.18 (04/25 18:38)
文章代碼(AID): #16R0_pwG (EZsoft)
文章代碼(AID): #16R0_pwG (EZsoft)