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

📄 尾插法建立但链表1.txt

📁 内容简介: 查找 递归 链表基本操作练习 排序 栈、队列基本操作练习 数据结构讲义
💻 TXT
字号:
///////////////////////////////////////////////
//			作者:03031A班  李戬			 //
//											 //
//		   2003年  xx月 xx日   晚			 //
///////////////////////////////////////////////
#include<iostream.h>
#include<stdlib.h>
#include<stdio.h>
#include<malloc.h>
typedef int datatype;
typedef struct node
{
	datatype data;
	struct node *next;
}linklist;
void main()
{
	linklist *head,*s,*r;
	int i,j,k;
	cout<<"please enter a total number"<<endl;
	cin>>i;
	head=NULL;
	r=NULL;
	for(j=1;j<=i;j++)
	{
		cout<<"please enter a number:"<<endl;
		cin>>k;
		s=(linklist *)malloc(sizeof(linklist));
		s->data=k;
		if(head==NULL) head=s;
		else
			r->next=s;
		r=s;
		cout<<s->data<<endl;
	}
}

⌨️ 快捷键说明

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