Open GoogleCodeExporter opened 8 years ago
#include<stdio.h> typedef struct node{ int data; struct node *next; }ListNode,*ListNodePtr; void Creat_List(ListNodePtr L,int n){ ListNodePtr p,q; int i; int a; q=(ListNodePtr)malloc(sizeof(ListNode)); q->data=n; q->next=NULL; for(i=1;i<=n;i++){ p=(ListNodePtr)malloc(sizeof(ListNode)); printf("请输入第%d个元素:\n",i); scanf("%d",&a); p->data=a; p->next=q->next; q->next=p; } L=q; } void Print_List(ListNodePtr L){ ListNodePtr p=L->next; int i=1; for(i;i<=5;i++){ printf("第%d个数据为:%d\n",i,p->data); p=p->next; } } void main(){ int n=5; ListNodePtr L; Creat_List(L,n); Print_List(L); }
Original issue reported on code.google.com by kkerF...@gmail.com on 10 Oct 2011 at 2:11
kkerF...@gmail.com
[deleted comment]
L=q 改成 *L=*q
Original comment by Cdegre...@gmail.com on 15 Oct 2011 at 3:43
Cdegre...@gmail.com
Original issue reported on code.google.com by
kkerF...@gmail.com
on 10 Oct 2011 at 2:11