linklist.h

来自「将X插入到顺序表的适当位置」· C头文件 代码 · 共 53 行

H
53
字号
#include "iostream.h"
#include "malloc.h"

#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
#define NULL 0
typedef int Status;

typedef int ElemType;

typedef struct LNode{
	ElemType data;
	struct LNode *next;
}LNode,*LinkList;


void CreatList_L(LinkList &L)
{
	LNode *p,*q;
	int n;
	cout<<"请输入元素个数";
	cin>>n;
	L=new LNode;
	L->next=NULL;  p=L;
	for(int i=0;i<n;i++)
	{
		cout<<"请输入第"<<i+1<<"个数:";
		q=new LNode;
		cin>>q->data; 
		q->next=p->next;  p->next=q;  p=q;
		cout<<endl;
	}
}

void PrintList_L(LinkList L)
{
	LNode *p;
	cout<<"输出链表:"<<endl;
    p=L->next;
	while(p!=NULL) 
	{
		cout<<p->data<<"  ";
	    p=p->next;
	}
}



⌨️ 快捷键说明

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