⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 易学c++程序实例 本章主要讲述一些学习程序设计前需要了解的一些知识和一些学习程序设计的方法。并且对 C++语言作了一个简要的介绍。学好这一章
💻 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 + -