1. 程式人生 > >資料結構課程設計——學生成績管理系統

資料結構課程設計——學生成績管理系統

}
/************************************
* 功能描述:判斷學號是否重複
* 輸入引數:無
* 輸出引數:無
************************************/
int num(LNode *a)//判斷學號是否重複
{
  LNode *p=head;
  while(p)
  {
     if (p->num==a->num)
     {
    return 0;  
     }
      p= p->next;
  }
    return 1;
}
/************************************
* 功能描述:根據輸入的學號修改成績
* 輸入引數:學生學號
* 輸出引數:無
************************************/
void ChangeMarkByNum()//根據學號修改學生成績
{
    LNode *p;//////////
    string num;
 int m;
    float mark1;
 float mark2;
 float mark3;
    p=head;//////////
    cout<<"請輸入學生學號: "<<endl;
    cin>>num;
    while(p)
    {
        if(p->num==num)
        {
            cout<<"學生姓名: "<<p->name<<endl;
      cout<<"學生學號: "<<p->num<<endl;
   cout<<"學生班級: "<<p->classname<<endl;
      cout<<"c語言:    "<<p->Cmark<<endl;
   cout<<"數學:     "<<p->Math<<endl;
   cout<<"英語:     "<<p->English<<endl;
            cout<<"是否要修改學生成績?"<<endl;
   cout<<" 1.是    2.不是    "<<endl;
   cin>>m;
   if(m==1)
   {
    cout<<"請輸入新的c語言成績"<<endl;
    cin>>mark1;
    cout<<"請輸入新的高數成績"<<endl;
    cin>>mark2;
    cout<<"請輸入新的英語成績"<<endl;
    cin>>mark3;
    p->Cmark=mark1;
    p->Math=mark2;
    p->English=mark3;
    cout<<"成績修改成功!"<<endl;
    cout<<"學生姓名: "<<p->name<<endl;
          cout<<"學生學號: "<<p->num<<endl;
    cout<<"學生班級: "<<p->classname<<endl;
          cout<<"c語言:    "<<p->Cmark<<endl;
    cout<<"數學:     "<<p->Math<<endl;
    cout<<"英語:     "<<p->English<<endl;
    return;
   }
   if(m==2)
   {
    cout<<"學生成績保留!"<<endl;
    return;
   }
            break;
        }
        p=p->next;
    }
 //////////////
       cout<<"對不起,不存在學號為"<<num<<"的學生"<<endl;
}
/************************************
* 功能描述:輸出一個結點資訊
* 輸入引數:無
* 輸出引數:輸出學生的姓名、學號、
*            班級、成績1、成績2、成績3
************************************/
void shuchujiedian(LNode *p)//輸出一個結點資訊
{
     cout<<"************************"<<endl;
  cout<<"學生姓名: "<<p->name<<endl;
  cout<<"學生學號: "<<p->num<<endl;
  cout<<"學生班級: "<<p->classname<<endl;
  cout<<"c語言:    "<<p->Cmark<<endl;
  cout<<"數學:     "<<p->Math<<endl;
  cout<<"英語:     "<<p->English<<endl;
  cout<<"平均成績: "<<(p->Cmark+p->Math+p->English)/3<<endl;
        cout<<"************************"<<endl;
}
/************************************
* 功能描述:不及格學生成績
* 輸入引數:無
* 輸出引數:不及格的資訊
************************************/
void DesplayMarkSegment()//輸出不及格的學生成績
{
      LNode *p=head;
   int count=0;
   cout<<"60分以下(不及格)的學生成績如下: "<<endl;
   while(p)
   {
    if(p->Cmark<60 || p->Math<60 || p->English<60)
    {
     count++;
     shuchujiedian(p);
    }
    p=p->next;
   }
   cout<<"不及格的學生一共有"<<count<<"人"<<endl;
}