⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 试用.cpp

📁 这是一个很经典的学生成绩管理系统..希望对大家有帮助
💻 CPP
字号:
#ifndef    STUDENT_H
#define    STUDENT_H
#include<iostream.h>
#include<string.h>
class   student
{
 friend  class  list;
private:
 char name[10];
 double grade[3];
public:
 student(){next=0;}
 void   s();
 student  *next;
   char *     outname(){return name;};
   double    outgrade(int i){return grade[i];};
   void      intgrade();
};
void  student::intgrade()
{    cout<<" 请输入计文成绩\n";
  cin>>grade[0];cout<<"请输入C++成绩\n";
  cin>>grade[1];cout<<"请输入形势政治成绩\n";
  cin>>grade[2];
}
 void student::s()
 {   
  cout<<"请输入姓名\n";
  cin>>name;
     cout<<"请输入计文成绩\n";
  cin>>grade[0];cout<<"请输入C++成绩\n";
  cin>>grade[1];cout<<"请输入形势政治成绩\n";
  cin>>grade[2];
    
}
class list 
{ 
private:
  double high[3],low[3];
 double  totoal;  //aver[3],pass[3],everygrade[3][6];
 student *last,*first;
public:
 list(){last=0;first=0;totoal=0;};
 ~list();
  void     instu();
  void      outstu(char *);
  int      delstu(char *n);
  void      think();
  void     search(char s[10]);
  double   hi(int i);
  double   lo(int  i);
  void   av(int i);
  void     ev(int i);
};
list::~list()
{
 if(first!=0)
 { 
  student *p=first,*temp;
  while(p!=0){
     temp=p;
  p=p->next;
  delete temp;
  cout<<"ok\n";
 }
 }
}
void  list::instu()
{  student  *p=new student();
    p->s();
if(first==0){first=last=p;}else{last->next=p;last=p;}
   totoal++;
}
 
void     list::outstu(char *n)
{
 student *temp=first;for(;temp!=NULL;temp=temp->next)
 if(strcmp(temp->outname(),n)==0)
 {  cout<<"姓名        计文       C++         形势政治\n ";
  cout<<temp->outname()<<"        "<<temp->outgrade(0)<<"          "<<temp->outgrade(1)<<"          "<<temp->outgrade(2);}
 
 
}
int      list::delstu(char *n)
{
 student *temp=first,*p;if(strcmp(first->outname(),n)==0)
 { first->next=first;delete temp;}
 else if(temp->next!=0)
 {if(strcmp(temp->next->outname(),n)==0)
 {p=temp->next;temp->next=temp->next->next;delete p;}
   else temp=temp->next;}
 totoal--;
 cout<<"\n删除成功\n";
 return 0;
}
void      list::think()
{
 cout<<"人数"<<totoal<<endl;
 cout<<"计文、\n";
  cout<<"最高分"<<hi(0)<<"最低分"<<lo(0)<<"";
  av(0);
  ev(0);
    cout<<"C++\n";
  cout<<"最高分"<<hi(1)<<"最低分"<<lo(1);
  av(1);
  ev(1);
    cout<<"形势政治\n";
  cout<<"最高分"<<hi(2)<<"最低分"<<lo(2);
  av(2);
  ev(2);  
 
}
 

double   list::hi(int i)
{
  high[i]=0.00;
     student *temp=first;if(temp!=0)
  {if(temp->outgrade(i)>high[i])
   high[i]=temp->outgrade(i);
  temp=temp->next;
  }
    return high[i];
}

double   list::lo(int  i)
{
  low[i]=100;
     student *temp=first;if(temp!=0)
  {if(temp->outgrade(i)<low[i])
   low[i]=temp->outgrade(i);
  temp=temp->next;
  }
    return low[i];
}
void   list::av(int i)
{    double aver=0;
     student *temp=first;if(temp!=0)
  {aver+=temp->outgrade(i);
  temp=temp->next;
  }
  cout<<aver/totoal<<endl;
 
}
void     list::ev(int i)
{   int a=0,b=0,c=0,d=0,e=0,f=0;
 student *temp=first;if(temp!=0)
 {switch((int)temp->outgrade(i)/10)
 {
  case 10:a++;break;case 9:a++;break;
  case  8:b++;break;case 7:c++;break;
  case  6:d++;break;case 5:e++;break;
  default:f++;
 }
 temp=temp->next;
 }
 cout<<"100-90、"<<a<<"89-80、"<<"79-70、"<<b
  <<"69-60、"<<c<<"59-50、"<<d<<"50以下"<<f
  <<"及格"<<(a+b+c+d)/(a+b+c+d+f)*100<<'%'<<endl;
}
 
void  list::search(char s[10])
{
    student *temp=first;for(;temp!=NULL;temp=temp->next)
    if(strcmp(temp->outname(),s)==0)temp->intgrade();
}
 
 

#endif
 

void main()
{
 list will;
 int m=0;
 do{
 cout<<"//----------------------------------------------------------\\\n"
    <<"    1、 成绩的录入:包括学生姓名和各门课程成绩的录入。\n"
       <<"    2、 成绩的查询:可以根据姓名查询某个学生的成绩。\n"
       <<"    3、 成绩的修改:可以根据姓名来修改相应的学生的成绩。\n"
        <<"   4、 成绩的删除:可以指定删除某个学生的成绩。\n"
        <<"   5、 成绩的统计分析:包括总人数、最高成绩、最低成绩、平均成绩、\n"
        <<"     各个分数段的人数(100-90、89-80、79-70、69-60、59-50、50以下)、及格率。\n"
   <<"//----------------------------------------------------------\\\n";
     cin>>m;
 switch(m)
 {
 case 1:
 will.instu();
  break;
 case 2:
  char n[9];
  cout<<"请输入姓名\n";
  cin>>n;
  will.outstu(n);
  cout<<"\n";
  break;
  case 3:
  char nb[9];
  cout<<"请输入姓名\n";
  cin>>nb;
 will.outstu(nb);
 cout<<"\n";
 will.search(nb);
 
     break;
 case 4:
  char naa[9];
  cout<<"请输入姓名\n";
  cin>>naa;
  will.outstu(naa);
  will.delstu(naa);
  break;

 
 case 5:
  will.think();
 break;
 }
 cout<<"1,继续2,退出\n";
 cin>>m;
 }while(m==1);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -