程序很小很简单, 因为刚刚开始学,也不知道哪里是对的
哪里是错的, 还请帮忙看看~~~~~~
   
#include <iomanip>
#include <iostream>
#include <fstream>
#include <vector>
#include <conio.h>
#include <stdlib.h>
#include <string>
#include <process.h>
#include <stdio.h>
using namespace std;
struct student
{
char name[10];  /// 姓名
char  id[10];       ///  学号
float  total;    ///   总分
student *next;
};
//////////////////////////////////////////////////////////////
class stud
{
    student *p1,*p2,*head;
public:
  ~stud()       /////----析构函数------------------------
{
while(head)
{
  p1=head->next;
  delete head;
  head=p1;
}
}
///-------------------------------------------------------------
void output(student *head);     //  输出学生成绩
student * insert(student *head);  //  增加学生记录
student* del(student *head, char*p);   //  删除记录
int find(student *head,char *p)  ;    // 查找学生记录
    student* stat(student *head);        //排序统计函数
};
////////-----输出学生成绩-----------------/////////////////////
void stud::output (student *head)
{ p1=head;
    if(head==NULL)
   cout<<"对不起,这是空表,没有数据"<<endl;
while(p1!=NULL)
{
   cout<<p1->name<<"  "<<p1->id<<"  "<<p1->total<<endl;
   p1=p1->next ;
}
}
//////////-----------排序统计函数-----------/////////////////
student *stud::stat(student *head)
{
if(head==NULL)
{cout<<"错误,这还是一张空表"<<endl;
return head;
}
p2=head;
p1=p2->next;
while(p2->next)  //冒泡泡法, 呵呵`~~~
{ 
    
   if(p2->total > p1->total)
   {         // 把头指针指向当前比较小的节点
           p2->next=p1->next;     
     p1->next=head;        
     head=p1;
                // 把用于比较的两个指针复位             
      p2=head;      
     p1=p2->next ;
   }//----------------------------------------
   else
   {           // 指向下一个节点
    p2=p2->next ;
    p1=p2->next ;
   }//-------------------------------------------
}
cout<<"按学生总分排序成功"<<endl;
return head;
}
/////-----------删除记录-----------//////////////////////
student* stud::del (student *head,char *p)
{  
p1=head;
p2=NULL;
if(head==NULL)
{
          cout<<"ERROR, 这是一个空表!!"<<endl;
          return head;
}
while(strcmp(p1->name ,p)&& p1->next !=NULL)
{     p2=p1;
  p1=p1->next ;
}
if(!strcmp(p1->name ,p))
{   
  if(p1==head) 
        head=p1->next; 
    else
         p2->next=p1->next ;
cout<<"删除成功,OK"<<endl;
delete p1;
}
else
cout<<" 没找到姓名"<<p<<"的学生.\n"; //结点没找到
  
return head ;
}
///////-------------查找函数----------///////////////////
int stud::find (student *head,char *p)
{   
if(head ==NULL)
{
  cout<<"错误,这是一张空表"<<endl; return 1;
}
p2=head;
  
       while(strcmp(p2->name ,p) && p2->next  !=NULL)
                 p2=p2->next ;
    if(!strcmp(p2->name,p))
{
cout<<"姓名, 学号, 总分!!!"<<endl;
  cout<<p2->name<<"  "<<p2->id<<"  "<<p2->total<<endl;
}
      else
         cout<<"对不起,没有您要查找学生的记录"<<endl;           
    
return 0;
}
///////----------------增加学生记录-----------////////////////////////////
student *stud::insert (student *head)
{  p1=new student;
p2=head;
        cout<<"姓名, 学号, 总分!!!"<<endl;
      cin>>p1->name>>p1->id >>p1->total ;
  if(head ==NULL)
  {
   head=p1;
   p1->next =NULL;
    return head;
  }
  while(p2->next !=NULL)
            p2=p2->next;
       p2->next=p1;
        p1->next=NULL;
     return head;
}
///////////////////------------main函数--------//////////////////-----------
int main(void)
{   
    stud stu;
    student *head=NULL;     
    char choice;
char name[10];  
    while(1)
{   system("cls");
  cout<<"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓";
  cout<<"┃****************        学生成绩管理系统主菜单界面       ****************** ┃";
  cout<<"┃********** ★★★★★        ★★★★★★★         ★★★★★  *********** ┃";
  cout<<"┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫";
  cout<<"┃****************★            ①.增加学生成绩             ★****************┃";
  cout<<"┃****************★            ②.显示学生成绩             ★****************┃";
  cout<<"┃****************★            ③.排序统计成绩             ★****************┃";
  cout<<"┃****************★            ④.查找学生成绩             ★****************┃";
  cout<<"┃****************★            ⑤.删除学生成绩             ★****************┃";
  cout<<"┃****************★            ⑥.安全退出系统             ★****************┃";
  cout<<"┃                                                                            ┃";                                                      
  cout<<"┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
  cout<<" 请输入您的选择(0--6):";cout<<endl;
  cin>>choice; fflush(stdin);
  if(choice=='6')
  {   cout<<"谢谢使用,再见"<<endl;
   exit(0);
  }
  switch(choice)
  {
  case '1': 
   head=stu.insert (head);
   break;
  case '2':
    cout<<"姓名, 学号, 总分!!!"<<endl;
   stu.output (head);
   getch();
   break;
  case '3':
   head=stu.stat(head);
   getch();
   break;
  case '4':
   cout<<"请输入想要查找的学生姓名"<<endl;
      cin>>name;
   
  stu.find(head,name);
   getch();
   break;
  case '5':
         cout<<"请输入想要删除学生姓名"<<endl;
   
   cin>>name;
   head=stu.del(head,name);
   getch();
   break;
   
      default :
    cout<<" 对不起,您的输入有误,请重新输入。\n";
    getch();
        break;
  }
}
getch();
return 0;
}
///***********************************************************************
[此贴子已经被作者于2007-3-30 22:52:12编辑过]



											

	    

	
