8 12 56 4 6 55 15 33 62
12 56 4 6 55 15 33 62
1 #include<stdio.h> 2 #include<stdlib.h> 3 struct node 4 { 5 int data; 6 struct node*next; 7 }; 8 int main() 9 { 10 int n ,i ; 11 struct node*head,*p,*tail; 12 head = (struct node*)malloc(sizeof(struct node)); 13 head->next = NULL; 14 tail = head; 15 scanf("%d",&n); 16 for(i = 0;i<n;i++) 17 { 18 p = (struct node*)malloc(sizeof(struct node)); 19 scanf("%d",&p->data); 20 p->next = NULL; 21 tail->next = p; 22 tail = p; 23 } 24 for(p = head->next;p!=NULL;p=p->next) 25 { 26 if(p->next==NULL) 27 printf("%d\n",p->data); 28 else printf("%d ",p->data); 29 } 30 return 0; 31 }
原文:https://www.cnblogs.com/xiaolitongxueyaoshangjin/p/12061679.html