该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
struct node
{
int num;
struct node *next;
};
void main()
{
struct node *create();
void print();
struct node *head;
head=NULL;
head=create(head);
print(head);
}
struct node *create(struct node *head)
{
struct node *p1,*p2;
p1=p2=(* struct node)malloc(sizeof(struct node));
scanf("%d",&p1->num);
p1->next=NULL;
while(p1->num!=-999)
{
if(head==NULL)
head=p1;
else p2->next=p1;
p2=p1;
p1=(struct node *)malloc(sizeof(struct node));
scanf("%d",&p1->num);
p1->next=NULL;
}
return head;
}
void print(struct node *head)
{
struct node *temp;
temp=head;
while(temp!=NULL)
{
printf("%6d",temp->num);
temp=temp->next;
}
}
各位帮忙看看有什么错误,为什么运行不了?