s3.cpp
来自「这是清华大学出版社的《数据结构》的电子文档讲义」· C++ 代码 · 共 28 行
CPP
28 行
// s3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stackQueue.h"
int main(int argc, char* argv[])
{
queueList<int> ql1,ql2;
ql1.makeEmpty(); ql2.makeEmpty();
int c[9] = {5, 6, -8,3,-4,-9,0,1,7};
for(int i=1; i<9; i++) {
if(c[i]>c[i-1]) ql1.enQueue(c[i]);
else{
while(!ql1.isEmpty()) ql2.enQueue(ql1.deQueue());
ql1.enQueue(c[i]);
while(!ql2.isEmpty()) ql1.enQueue(ql2.deQueue());
}
}
cout<<"ql1中为:"; //ql1为:-9,-4,-8,6,3,0,1,7
while(!ql1.isEmpty()) cout<<ql1.deQueue()<<", ";
cout<<endl;
cout<<"ql2中为:"; //ql2为:
while(!ql2.isEmpty()) cout<<ql2.deQueue()<<", ";
cout<<endl;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?