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

📄 头插法建立链表.txt

📁 C语言数据结构源代码
💻 TXT
字号:
///////////////////////////////////////////////
//			作者:03031A班  李戬			 //
//											 //
//		   2003年  xx月 xx日   晚			 //
///////////////////////////////////////////////
#include<iostream.h>
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
typedef int datatype;
typedef struct node
{
	datatype data;
	struct node *next;
}linklist;
void jay(linklist *a)
{
	if(a->next!=NULL)
	{
		cout<<a->data<<endl;
		jay(a->next);
	}
}
void main()
{
	char ch;
	linklist *head,*s;
	head=NULL;
	cout<<"please enter a charter:"<<endl;
	cin>>ch;
	while(ch!='&')
	{
		s=(linklist *)malloc(sizeof(linklist));//建立新节点
		s->data=ch;//向新节点中添加内容
		s->next=head;//使新节点指向链首
		head=s;//改变头指针
		cout<<"please enter a charter:"<<endl;
		cin>>ch;
	}
	cout<<head->data<<endl;
	jay(s);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -