//栈操作
#define MAXSIZE 300
int st[MAXSIZE],tp=0;
void push(int x){st[++tp]=x;};
void pop(){--tp;};
int top(){return st[tp];};
bool empty(){return!tp;};
int size(){return tp;};
void clear(){tp=0;};
//队列操作
#define MAXSIZE 300
int l = 1,r = 0,qu[MAXSIZE];
void push(int x){qu[++r] = x;};
int front(){return qu[l];};
void pop(){l++;};
int empty(){return l > r ? 1 : 0;};
int size(){return r-l+1;};
//sort排序
int a[101];
void Sort(int l,int r)
{
if(l>=r) return;
else
{
int i=l;
int j=r;
int top=a[i];
while(i<j)
{
while(top<=a[j] && (i<j)) j--;
a[i]=a[j];
while(a[i]<=top && (i<j)) i++;
a[j]=a[i];
}
a[i]=top;
Sort(l,i-1);
Sort(i+1,r);
}
}
上机tips(手写STL)
最新推荐文章于 2024-07-05 17:24:57 发布