尾插法建立链表,输不出结果!
#include<stdio.h>#include<malloc.h>
struct clone
{
int data;
struct clone *next;
};
int main()
{
int n,x;
int i=0;
printf("input n\n");
scanf("%d",&n);
struct clone *l,*p;
while(i<n)
{
scanf(" %d",&x);
l=(struct clone *)malloc(sizeof(clone));//尾插法建立链表
l->data=x;
p->next=l;
p=l;
i++;
}
p->next=NULL;
struct clone *m=p->next;
while(m!=NULL)
{
printf("%d",m->data);
m=m->next;
}
return 0;
}