线性表

栈&队列

二叉树

持续更新中,尽请期待!!!

#include<iostream>
using namespace std;

typedef char datatype;
typedef struct node
{
   
	datatype data;
	struct node *next;
} Lnode, *linklist;

void creat(linklist &head)
{
   
	char ch;
	linklist s,r;
	head = new Lnode;
	r=head;
	while((ch=getchar())!='*')//到“ * ”结束
	{
   
		s = new Lnode;
		s->data=ch;
		r->next=s;
		r=s;
	}
	r->next=NULL;
}
void invert(linklist &head)
{
   
	linklist p, q, r;
	p=head->next;
	q=p->next;
	while(q!=NULL)
	{
   
		r=q->next;
		q->next=p;
		p=q;
		q=r;
	}
	head->next->next=NULL;
	head->next=p;
}
void print(linklist &head)
{
   
	linklist p=head->next;
	while(p!=NULL)
	{
   
		cout<<p->data<<" ";
		p=p->next;
	}
	cout<<endl;
}
int main()
{
   
	linklist head;
	creat(head);
	print(head);
	invert(head);
	print(head);
	return 0;
}