帮我这只菜鸟看看这个程序错在那里,应如何改正
////////////////////////////////////////////////////////////////
//===============written ========================//
//////////////////////////////////////////////////////////////
#include<iomanip.h>//学生成绩管理系统的链表实现
#include<string.h>
//===============declaration================================//
class node{//节点类
friend class list;
public:
void getdata();
// ~node(){delete next;}
private:
char number[10];
char name[10];
bool sex;
float score[4];
node * next;
};
void node::getdata(){//赋值函数
char rtemp[10];
float rscore;
int temp;
cout<<"Name:";
cin>>rtemp;
strcpy(name,rtemp);
cout<<"Number:";
cin>>rtemp;
strcpy(number,rtemp);
cout<<"Sex(0-female,1-male):";
cin>>temp;
while(!(temp==0||temp==1)){
cout<<"\n对不起,输入错误,请重输!\nSex(0-female,1-male):";
cin>>temp;
}
if(temp==1) sex=true;
else sex=false;
for(int j=0;j<4;j++){
cout<<"Score"<<j<<":";
cin>>rscore ;
score[j]=rscore;
}
cout<<endl;
}
//----------------------------------------------------------------------//
class list{//ADT表类
public:
list(){first=NULL;}
~list();
bool search(const char *x);
bool Insert(int k,node &x);
bool Delete(int k);
void PrintList(ostream & out);
private:
node* first;
};
list::~list()//析构函数
{
node *p;
while(first){
p=first->next;
delete first;
first=p;
}
}
bool list::search(const char *x )//按学号查找
{
bool success=false;
node * p=first;
int k=1;
while(strcmp(p->number,x)!=0 && p){
p=p->next;
k++;
}
if(p) {
success=true;
cout<<"该记录为第"<<k<<"条"<<":";
cout<<"name:"<<
p->name<<";number:"<<p->number
<<";sex:";
if(p->sex=true) cout<<"male";
else cout<<"female";
for(int j=0;j<4;j++){
cout<<";score"<<j<<":"<<p->score[j]
<<"."<<endl<<endl; }
}
return success;
}
void list::PrintList(ostream & out)//输出ADT表
{
node *p=first;
int i=1;
while(p){
out<<"No"<<i<<":"<<endl<<"name:"<<
p->name<<";number:"<<p->number
<<";sex:";
if(p->sex=true) out<<"male";
else out<<"female";
for(int j=0;j<4;j++){
out<<";score:"<<j<<p->score[j]
<<"."<<endl<<endl;}
p=p->next;
}
}
bool list::Insert(int k,node &x)//在第k个元素后插入
{
bool success=false;
node * p=first;
int s=1;
if(k==0) {
if(!first){
first=new node;
first->next=NULL;
}
x.next=first->next;
first=&x;
success=true;
}
else if(k>0){
if(p && s!=k){
s++;
p=p->next;
}
if(p){
x.next=p->next;
p=&x;
success=true;
}
}
return success;
}
bool list::Delete(int k)//删除第k个元素后的元素
{
bool success=false;
node * p=first;
int s=1;
if(k==0 && p) {
first=first->next;
success=true;
}
else if(k>0){
if(s!=k && p->next){
p=p->next;
s++;
}
if(p->next){
p=p->next->next;
success=true;
}
}
return success;
}
//=================end of declration============================//
//=================main function===============================//
void createadt(int n,list & x);
void insert(list &x);
void Delete(list &x);
void search(list &x);
void print(list &x);
void main()
{
int n;
list x;
cout<<"********************************"<<endl;
cout<<"********************************"<<endl;
cout<<"* ◎欢迎进入学生成绩管理系统◎ *"<<endl;
cout<<"********************************"<<endl;
cout<<"********************************"<<endl<<endl;
cout<<"请先建立一张表!"<<endl<<endl;
cout<<"输入表中的记录数:";
cin>>n;
while(n<0){
cout<<"对不起,输入错误!\n请重新输入:";
cin>>n;
}
cout<<"\n开始建表......"<<endl;
createadt(n,x);
cout<<"......建表结束\n";
do{
cout<<"请选择操作\n1.插入 2.删除 3.查询 4.打印 5.退出"<<endl;
cin>>n;
while(n<1||n>5){
cout<<"对不起,输入错误!\n请重新输入:";
cin>>n;
}
cout<<"\n执行操作......"<<endl;
switch(n){
case(1):insert(x);break;
case(2):Delete(x);break;
case(3):search(x);break;
case(4):print(x);break;
}
} while(n!=5);
cout<<"感谢使用本管理系统!\n请真诚提出建议,谢谢!\n再见!!";
// char m;
// cin>>m;
}
//========================end of main function=========================================//
void createadt(int n,list & x)
{
for(int i=1;i<=n;i++)
{ cout<<"No"<<i<<":"<<endl;
node a;
a.getdata();
x.Insert(i-1,a);
}
}
//-----------------------------------------------------------------------------//
void insert(list &x)
{
cout<<"请输入插入的记录有关信息:"<<endl;
node a;
a.getdata();
cout<<"需要插入在第几条的后面:";
int j;
cin>>j;
if(x.Insert(j,a)) cout<<"\n插入成功"<<endl;
else cout<<"\n对不起,插入失败"<<endl;
}
//----------------------------------------------------------------------------//
void Delete(list &x)
{
cout<<"需要在第几条的后面删除:";
int j;
cin>>j;
if(x.Delete (j)) cout<<"\n删除成功"<<endl;
else cout<<"\n对不起,输入有误,删除失败"<<endl;
}
//---------------------------------------------------------------------------//
void search(list& x)
{
cout<<"输入要查询的学生学号:";
char *a;
cin>>a;
if(!x.search(a)) cout<<"您要查询的记录不存在!\n";
}
//---------------------------------------------------------------------------//
void print(list& x)
{
x.PrintList(cout);
}