linklist.h

来自「题目:A、B两个以单链表做存储结构的递增有序排列的链表合并为一个单链表做存储结构」· C头文件 代码 · 共 49 行

H
49
字号
#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,int n)
{
	LNode *p,*q;
	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;
	}
	cout<<endl;
}

⌨️ 快捷键说明

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