#include<stdio.h>
#include<stdlib.h>
typedef struct LNode {
int date;
struct LNode* next;
}LNode, * LinkList;
LinkList List_TailIsert(LinkList& L) {
int x;
L = (LinkList)malloc(sizeof(LNode));
LNode* s, * r = L;
scanf("%d", &x);
while (x != 9999) {
s = (LNode*)malloc(sizeof(LNode));
s->date = x;
r->next = s;
r = s;
scanf("%d", &x);
}
r->next = NULL;
return L;
}
void PrintList(LinkList L) {
LinkList P;
P = L->next;
while (P != NULL)
printf("%d", P->date);
P = P->next;
}
int main() {
LNode* L;
List_TailIsert(L);
PrintList(L);
return 0;
}
而且这个代码不知道哪里错了,输入数字之后再输入9999打印不出来链表
LinkList List_TailIsert(LinkList& L) 引用是c++的东西,文件名后缀名要为cpp
void PrintList(LinkList L)
{
LinkList P;
P = L->next;
while (P != NULL) //缺花括号
{
printf("%d", P->date);
P = P->next;
}
}