谁能帮我调试成功了,给50分
#include<iostream.h>
#include<string.h>
struct Student
{
char name[10];
Student* next;
};
Student* head;
Student* re(Student* pl);
Student* Create()
{
Student* pS;
Student* pEnd;
pS=new Student;
cout<<"please input a student name."<<endl;
cin.getline(pS->name,sizeof(pS->name));
head=NULL;
pEnd=pS;
while(!strcmp(pS->name,"exit"))
{
if(head==NULL)
{
head=pS;
pS->next=NULL;
}
else
{
pEnd->next=pS;
}
pEnd=pS;
cout<<"please input a student name."<<endl;
pS=new Student;
cin.getline(pS->name,sizeof(pS->name));
}
pEnd->next=NULL;
delete pS;
return(head);
}
void ShowList(Student* head)
{
Student* ps=head;
cout<<"now the items of list are \n";
while(ps!=NULL)
{
cout<<ps->name<<endl;
ps=ps->next;
}
return;
}
void main()
{
ShowList(Create());
Student* pw=new Student;
strcpy(pw->name,"mant");
re(pw);
ShowList(head);
return;
}
Student* re(Student* pl)
{
Student* pb,*ph;
ph=head;
if((ph->name)=="jone")
{
pl->next=ph;
head=pl;
return head;
}
while(ph)
{
pb=ph;
ph=pb->next;
if((ph->name)=="jone")
{
pb->next=pl;
pl->next=ph;
return head;
}
}
pb->next=pl;
pl->next=NULL;
return head;
}