📄 main.cpp
字号:
#include "iostream.h"
struct node
{
char operation;
node * next;
};
node * create();
void showList(node *head);
void destory(node * &head);
void main()
{
node *head;
head=create();
showList(head);
destory(head);
}
node * create()
{
node *head=NULL;
node *pEnd=head;
node *pGuard;
node *pS;
char temp;
cout <<"请输入指令:" <<endl;
do
{
cin >>temp;
if (temp!='#')
{
if (temp!='$')
{
pS=new node;
pS->operation=temp;
pS->next=NULL;
if (head==NULL)
{
head=pS;
}
else
{
pEnd->next=pS;
}
pGuard=pEnd;
pEnd=pS;
}
else
{
pGuard->next=NULL;
delete pEnd;
pEnd=pGuard;
for (pGuard=head;pGuard->next->next!=NULL;pGuard=pGuard->next);
}
}
}while (temp!='#');
return head;
}
void showList(node *head)
{
node *pRead=head;
cout <<"用户的实际操作是:" <<endl;
while (pRead!=NULL)
{
cout <<pRead->operation;
pRead=pRead->next;
}
cout <<endl;
}
void destory(node * &head)
{
node *p;
while (head!=NULL)
{
p=head;
head=head->next;
delete p;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -