诸位大神,在主函数里怎样调用这个函数?
Student*creat(void){intn;Student*head,*p1,*p2;n=0;p1=p2=newStudent;cin>>p1->num>>p1->...
Student* creat(void)
{int n;
Student *head,*p1,*p2;
n=0;
p1=p2=new Student;
cin>>p1->num>>p1->score;
head=p1;
while(p1->num!=0)
{
n=n+1;
p2->next=p1;
p1=new Student;
cout<<"please input student"<<n<<"'s data:"<<endl;
cout<<"NO.";
cin>>p1->num;
cout<<endl<<"score:";
cin>>p1->score;
p2=p1;
}
p2->next=NULL;
return(head);
} 展开
{int n;
Student *head,*p1,*p2;
n=0;
p1=p2=new Student;
cin>>p1->num>>p1->score;
head=p1;
while(p1->num!=0)
{
n=n+1;
p2->next=p1;
p1=new Student;
cout<<"please input student"<<n<<"'s data:"<<endl;
cout<<"NO.";
cin>>p1->num;
cout<<endl<<"score:";
cin>>p1->score;
p2=p1;
}
p2->next=NULL;
return(head);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询