Student *p ;
cout< for(p = Head->next ; p != End ; p = p->next) p->show() ; cout<<\输入任意字符,继续......\ getch() ; } void StudentMassage::AddItem() //添加学生信息 { End->input() ; End->next = new Student ; End = End->next ; cout<<\添加成功!\ cout<<\输入任意字符,继续......\ getch() ; } void StudentMassage::Find() //查找函数 { char name[20] , id[20] ; int x ; Student *p = NULL ; cout<<\ cout<<\、按学生姓名查找\ cout<<\、按学生学号查找\ cout<<\请选择:\ cin>>x ; switch(x) { case 1: //按姓名查找 { cout<<\请输入要查找的学生的姓名:\ cin>>name ; if(p = FindItem(name)) { cout< cout<<\请输入任意字符,继续......\ getch() ; } else { 11 cout<<\没有找到该姓名的学生!\ cout<<\请输入任意字符,继续......\ getch() ; } } break ; case 2: //按学号查找 { cout<<\请输入要查找的学生的学号:\ cin>>id ; if(p = FindId(id)) { cout< cout<<\请输入任意字符,继续......\ getch() ; } else { cout<<\没有找到该学号的学生!\ cout<<\请输入任意字符,继续......\ getch() ; } } break ; } } void StudentMassage::ModifyItem() //修改学生信息 { char name[20] ; Student *p = NULL ; cout<<\请输入要修改的学生的姓名:\ cin>>name ; if(p = FindItem(name)) { cout<<\已找到该学生,请输入新的信息!\ p->next->input() ; cout<<\修改成功!\ Display() ; } else { cout<<\没有找到!\ cout<<\输入任意字符!继续.......\ getch() ; 12 } } void StudentMassage::RemoveItem() //删除学生信息 { char name[20] ; Student *p = NULL , *temp = NULL ; cout<<\请输入要删除的学生的姓名:\ cin>>name ; if(p = FindItem(name)) { temp = p->next ; p->next = p->next->next ; delete temp ; cout<<\删除成功!\ Display() ; } else { cout<<\没有找到!\ cout<<\输入任意字符!继续......\ getch() ; } } int StudentMassage::ListCount() //返回记录的学生总数 { Student *p ; int n = 0 ; if(!Head) return 0 ; for(p = Head->next ; p != End ; p = p->next) n ++ ; return n ; } int StudentMassage::Count() //成绩统计 { Student *p ; int x , m , n ,count = 0 ; if(!Head) { cout<<\没有资料可以统计!\ return 0 ; 13 } cout<<\ cout<<\、统计数学成绩\ cout<<\、统计语文成绩\ cout<<\、统计英语成绩\ cout<<\ cout<<\请选择:\ cin>>x ; switch(x) { case 1 : { cout<<\请输入分数段的起始分数和终止分数:\ cin>>m ; cin>>n ; for(p = Head ; p != End ; p = p->next) if(p->math >=m && p->math <= n) { count ++ ; if(count == 1) cout< cout<<\数学成绩在\的学生共有\人!\\n\ cout<<\输入任意字符,继续.......\ getch() ; } ; break ; case 2: { cout<<\请输入分数段的起始分数和终止分数:\ cin>>m ; cin>>n ; for(p = Head ; p != End ; p = p->next) if(p->chinese >=m && p->chinese <= n) { count ++ ; if(count == 1) cout< cout<<\语文成绩在\的学生共有\人!\\n\ cout<<\输入任意字符,继续.......\ 14 getch() ; } ; break ; case 3: { cout<<\请输入分数段的起始分数和终止分数:\ cin>>m ; cin>>n ; for(p = Head ; p != End ; p = p->next) if(p->english >=m && p->english <= n) { count ++ ; if(count == 1) cout< cout<<\英语成绩在\的学生共有\人!\\n\ cout<<\输入任意字符,继续.......\ getch() ; } ; break ; } } void StudentMassage::Swap(Student *p1 , Student *p2) //交p1,p2学生信息 { Student *temp = new Student ; strcpy(temp->name , p1->name) ; strcpy(temp->id , p1->id) ; temp->math = p1->math ; temp->chinese = p1->chinese ; temp->english = p1->english ; temp->sum = p1->sum ; strcpy(p1->name , p2->name) ; strcpy(p1->id , p2->id) ; p1->math = p2->math ; p1->chinese = p2->chinese ; p1->english = p2->english ; p1->sum = p2->sum ; strcpy(p2->name , temp->name) ; strcpy(p2->id , temp->id) ; p2->math = temp->math ; p2->chinese = temp->chinese ; p2->english = temp->english ; 15