作者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://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
1F:推 hpo14:还蛮酷的 06/10 22:58
2F:推 JMWang:X....太帅了 06/10 22:59
3F:→ kewang:大推 06/10 23:00
4F:推 twico:L大~ 大推 06/10 23:03
5F:推 kewang:可是好像不支援fx?? 06/10 23:03
6F:推 LiloHuang:复制的功能不能支援 要自己Ctrl+A全选复制唷^^" 06/10 23:07
7F:推 aiyswu:PUSH 06/10 23:21
8F:推 mocolin:好酷阿 06/11 00:37
9F:推 chris:cool! 06/11 08:07
10F:推 youbet:推推推 06/11 10:25
11F:推 pcsony:推~~~~~~~~ 06/11 10:32
12F:推 starshine:推一个 酷~ 06/11 13:29
13F:推 montreal:为甚麽last也被标色? 06/11 13:29
14F:推 LiloHuang:last是Perl语法...我会再新增可以选择要哪种语言 06/11 14:17
15F:推 asoedarren:可以转到程式版吗? 06/11 16:23
16F:推 alicekey:原po自己写的程式? 06/11 16:23
17F:推 LiloHuang:sure:) 06/11 19:00
※ macau1220:转录至看板 HKday 12/19 20:22
※ 编辑: LiloHuang 来自: 211.79.63.18 (04/25 18:38)