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

📄 main.cpp

📁 易学c++源码
💻 CPP
字号:
#include <iostream>
using namespace std;
struct node
{
	char person;
	node * next;
};
node * create();
void destory(node * &head);
int main()
{
	node *head;
	head=create();
	destory(head);
	return 0;
}
node * create()
{
	int time=0;
	node *head=NULL;
	node *pEnd=head;
	node *pGuard;
	node *pS;
	char temp;
	cout <<"请输入序列:";
	do
	{
		cin >>temp;
		if (temp!='#')
		{
			if (temp!='$')
			{
				time++;
				pS=new node;
				pS->person=temp;
				pS->next=NULL;
				if (head==NULL)
				{
					head=pS;
					pGuard=head;
				}
				else
				{
					pEnd->next=pS;
				}
				pEnd=pS;
			}
			else
			{
				head=head->next;
				cout <<pGuard->person <<' ' <<time <<'s' <<endl;
				delete pGuard;
				pGuard=head;
			}				
		}
	}while (temp!='#');
	return head;
}
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 + -