#include <stdio.h>
#include <malloc.h>
typedef struct Node{
int data;
struct Node* next;
}Node;
int main(void){
int i;
Node* head,*p=NULL;
head=(Node*)malloc(sizeof(Node));
head->next=p;
for(i=0;i<4;i++){
p=(Node*)malloc(sizeof(Node));
printf("输入:");
scanf("%d",&p->data);
p->next=head->next;
head->next=p;
}
while(NULL!=head){
printf("%d\n",head->data);
head=head->next;
}
}
#include <stdio.h>
#include <malloc.h>
typedef struct Node{
int data;
struct Node* next;
}Node;
int main(void){
int i;
Node* end=NULL;
Node* p=NULL;
Node* head=(Node*)malloc(sizeof(Node));
end=head;
for(i=0;i<4;i++){
p=(Node*)malloc(sizeof(Node));
printf("输入:");
scanf("%d",&p->data);
end->next=p;
end=p;
}
end->next=NULL;
while(NULL!=head){
printf("%d\n",head->data);
head=head->next;
}
}