一个链表的模拟操作程序

源代码在线查看: 链表操作.txt

软件大小: 2 K
上传用户: abc171abc171
关键词: 模拟操作 程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				#include"iostream.h"
				#include"process.h"
				//-----------------------------------------------------------
				template 
				struct lian
				{
				lian * next;
				t zhi;
				
				lian()
				{
				next=NULL;
				zhi=0;
				}
				//-----------------------------------------------------------
				
				friend ostream& operator 				{
				for (;a!=NULL;)
				{
				cout				a=a->next ;
				}
				return cout;
				
				}
				//-------------------------------------------------------------
				friend istream& operator >> (istream& cin,lian *a)
				{
				cin>>a->zhi;
				return cin;
				
				}
				//----------------------------------------------------------------
				
				lian * creat (lian * a)
				{
				cout				int length;
				cin>>length;
				lian * top=a;
				
				for (int i=1;i				{
				cout				
				lian * jiedian;
				jiedian=new lian;
				cin>>jiedian;
				top->next=jiedian;
				top=jiedian;
				
				
				}
				return a;
				}
				//----------------------------------------------------------
				
				lian * lianjie(lian *a,lian * b)
				{
				lian *wei=a;
				
				for(;wei->next!=NULL;)
				{
				wei=wei->next;
				}
				wei->next=b;
				return a;
				
				
				}
				
				
				
				
				
				
				};
				
				
				main()
				{
				
				for (int i=1;i;)
				{
				cout				cout				cout				cout				
				
				int choice;
				cin>>choice;
				//--------------------------------------------------------
				switch (choice)
				{
				case 1:
				cout				lian *a;
				a=new lian;
				a->creat (a);
				cout				lian *b;
				b=new lian;
				b->creat(b);
				
				
				break;
				//--------------------------------------------------------
				case 2:
				cout				a->lianjie(a,b);
				break;
				case 3:
				cout				cout				break;
				
				//---------------------------------------------------------
				case 4:
				
				exit(1);
				break;
				
				}
				}//for语句的结尾-------------------------------------
				
				
				
				
				
				
				
				
				
				}
				
				
				
				
							

相关资源