#include<bits/stdc++.h>
using namespace std;
//链表
typedef struct LNode
{
int data;
struct LNode* next;
}* LinkList;
void CreateList_L(LinkList& L)
{
int input;
L =(struct LNode*)malloc(sizeof(LNode));
L->next = NULL;
LinkList p = L;
while(scanf("%d",&input)&&input!=0)//输入以0为终止条件
{
LinkList temp;
temp = (struct LNode*)malloc(sizeof(LNode));
temp->data = input;
temp->next = p->next;//优先考虑temp-next的连接
p->next = temp;
// p = p->next;
}
}
void PrintList_L(LinkList& L)
{
LinkList p = L->next;
while(p)
{
cout<<p->data<<" ";
p = p->next;
}
printf("\n");
}
int main()
{
LinkList La;
CreateList_L(La);
PrintList_L(La);
return 0;
}
11-20
1382

07-17
382
