源代码:
#include<iostream>
#include<cstring>
#define OK 1
#define ERROR 0
#define OVERFLOW -1
using namespace std;
typedef int Elemtype;
typedef struct LNode {
Elemtype date;
struct LNode *next;
} LNode,*linkList;
int inti(linkList &l) {
l= new LNode;
l->next=NULL;
return OK;
}
void creat(linkList &l) {
int n;
linkList p;
printf("2. 请输入链表的长度:");
scanf("%d",&n);
cout<<" 请输入值:";
for(int i=0; i<n; i++) {
p = new LNode;
cin>>p->date;
p->next=l->next;
l->next=p;
}