创建动态 链表 出现错误帮忙看看呢
#include <iostream>using namespace std;
#define NULL 0
struct student
{long num;
float score;
student *next;
};
int main()
{student *head;
student *p1,*p2,*k;
int n=0;
p1=new student;
p2=new student;
cout<<"请输入第1个节点";
cin>>p1->num>>p1->score;
head=NULL;
while(p2->num!=0)
{n=n+1;
if(n==1) head=p1;
else p1->next=p2;
p2=p1;
p2=new student;
cout<<"请输入第 "<<n+1<< "个节点";
cin>>p2->num>>p2->score;
}
p2->next=NULL;
k=head;
do
{
cout<<k->num<<k->score<<endl;
k=k->next;
}
while(k!=NULL);
}