📄 3.cpp
字号:
#include<iostream.h>
#include"lqueue.h"
#include"Lstack1.h"
#include<conio.h>
main()
{
char zifu,temp1,temp2;
int y=3;
LQueue<char>lqueue;
LStack1<char>lstack;
cout<<"输入字符,以0结束";
cin>>zifu;
while(zifu!='0')
{
lqueue.enqueue(zifu);
cout<<"输入字符,以0结束";
cin>>zifu;
}
clrscr();
cout<<" 状态 未读入字符 栈中";
gotoxy(6,2);cout<<"s";gotoxy(19,2);lqueue.print();gotoxy(40,2);lstack.play();cout<<endl;
if(!lqueue.dequeue(temp1)) {cout<<"接受";goto end;}
s:
{
if(temp1=='a')
{ gotoxy(6,y);cout<<"s";gotoxy(19,y);lqueue.print();
lstack.push(temp1);
lqueue.dequeue(temp1);
gotoxy(40,y);lstack.play();cout<<endl;y++;
goto s;
}
else if(temp1=='b')
{gotoxy(6,y);cout<<"f";gotoxy(19,y);lqueue.print();goto f_temp;}
else {cout<<"不接受";goto end;}
}
f_temp:{
lstack.pop(temp2);
gotoxy(40,y);lstack.play();cout<<endl;y++;
}
f:
{
if(lqueue.dequeue(temp1))
{
if(temp1=='b')
{ if(lstack.pop(temp2))
{gotoxy(6,y);cout<<"f";gotoxy(19,y);lqueue.print();
gotoxy(40,y);lstack.play();cout<<endl;y++;goto f;}
else {cout<<"不接受";goto end;}
}
else {cout<<"不接受";goto end;}
}
else if(!lstack.pop(temp2))
{//gotoxy(6,y);cout<<"f";gotoxy(19,y);cout<<"e";
//gotoxy(40,y);cout<<"e";cout<<endl;y++;
cout<<" 接受";goto end;}
else cout<<"不接受";
}
end:
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -