注册 登录
编程论坛 C++ Builder

各位大虾,帮帮忙呀,实在不知道怎么改了

wds19840615 发布于 2007-12-10 10:42, 1028 次点击
#include<iostream>
#include<fstream>
using namespace std;
#include<string>
class student
{
 private:
     char num[10];
      char name[10];
      int grade;
      int clas;
      struct score1
      {float Chinese;
       float English;
       float Mathematics;
       float Physics;
       float Chemistry;
       float Biology;
      
            }S;
      struct score2
      {float Chineseps;
       float Englishps;
       float Mathematicsps;
       float Physicsps;
       float Chemistryps;
       float Biologyps;
      }PS;
      struct score3
      {float p2;
       float q3;
       float z3;
       float fd4;
       float fg5;
       float er6;
      }total;
     
public:
    
      char *getNumber();
      char *getName();
      int getgrade();
      int getclas();
      float getChinese();
      float getEnglish();
      float getMathematics();
      float getPhysics();
      float getChemistry();
      float getBiology();
      float getp2();
      float getq3();
      float getz3();
      float getfd4();
      float getfg5();
      float geter6();
      void Input();
      void Display();
};
char *student::getNumber()
{return num;
}
char *student::getName()
{return name;
}
int student::getclas()
{return clas;
}
int student::getgrade()
{return grade;
}
float student::getChinese()
{return S.Chinese;
}
float student::getMathematics()
{
       return S.Mathematics;
}

float student::getEnglish()
{

       return S.English;
}

float student::getPhysics()
{

       return S.Physics;
}

float student::getChemistry()
{

       return S.Chemistry;
}
float student::getBiology()
{

       return S.Biology;
}
float student::getp2()
{return S.Chinese*0.7+PS.Chineseps*0.3;
}
float student::getq3()
{return S.English*0.7+PS.Englishps*0.3;
}
float student::getz3()
{return S.Mathematics*0.7+PS.Mathematicsps*0.3;
}
float student::getfd4()
{return S.Physics*0.7+PS.Physicsps*0.3;
}
float student::getfg5()
{return S.Chemistry*0.7+PS.Chemistryps*0.3;
}
float student::geter6()
{return S.Biology*0.7+PS.Biologyps*0.3;
}

void student::Input()
{cout<<"请输入学生个人信息:"<<endl;
cout<<"学号:";cin>>num;
cout<<"姓名:";cin>>name;
cout<<"年级:";cin>>grade;
cout<<"班级:";cin>>clas;
cout<<"各科期末成绩:"<<endl;cout<<"语文"<<" ";cin>>S.Chinese;cout<<"英语"<<" ";cin>>S.English;
cout<<"数学"<<" ";cin>>S.Mathematics;cout<<"物理"<<" ";cin>>S.Physics;cout<<"化学"<<" ";
cin>>S.Chemistry;cout<<"生物"<<" ";cin>>S.Biology;cout<<endl;

cout<<"各科平时成绩:"<<endl;cout<<"语文"<<" ";cin>>PS.Chineseps;cout<<"英语"<<" ";cin>>PS.Englishps;
cout<<"数学"<<" ";cin>>PS.Mathematicsps;cout<<"物理"<<" ";cin>>PS.Physicsps;cout<<"化学"<<" ";
cin>>PS.Chemistryps;cout<<"生物"<<" ";cin>>PS.Biologyps;cout<<endl;
}
void student::Display()
{cout<<"输出学生个人信息:"<<endl;
cout<<"学号:"<<num<<" "<<"姓名:"<<name<<" "<<"年级:"<<grade<<" "<<"班级:"<<clas<<endl;
cout<<"各科期末成绩:"<<endl;
cout<<"语文"<<S.Chinese<<"英语"<<S.English<<"数学"<<S.Mathematics<<"物理"<<S.Physics
<<"化学"<<S.Chemistry<<"生物"<<S.Biology<<endl;
cout<<"各科总评成绩:"<<endl;
cout<<"语文"<<getp2()<<"英语"<<getq3()<<"数学"<<getz3()<<"物理"<<getfd4()
<<"化学"<<getfg5()<<"生物"<<geter6()<<endl;
}
class link_list
{private:
       struct linklist
       { student stu;
         struct linklist *next;
       }link;
 public:
     void creat();
     void find(linklist *head);
};
void link_list::creat()
{ struct linklist *p,*q,*head;
   char z;
    head=new  linklist;
    head->next=0;
    q=head;
    p=new (struct linklist);
    p->stu.Input();
    p->stu.Display();
     head->next=p;
     q=p;
    cout<<"是否继续输入?(Y/N)";cin>>z;
    while(z=='Y')
     {p=new (struct linklist);
          p->stu.Input();
          p->stu.Display();
          q->next=p;
          q=p;        
    }     
    
        cout<<"录入完成!"<<endl;
    
  
}
void find(linklist *head)
{ linklist *p;
  p=head;
  char number[10];
  cout<<"请输入该学生的学号:";
  cin>>number;
  while(p->next->stu.getNumber()==number)
       p=p->next;
     if(p->next==NULL)
         cout<<"该学生信息不存在,请确认!"
         cout<<"该学生成绩为:"<<p->next->stu->number<<" "
         <<p->next->stu->getName()<<p->next->stu->getgrade()
         <<p->next->stu->getclas()<<p->next->stu->getp2()<<
         p->next->stu->getq3()<<p->next->stu->getz3()<<
         p->next->stu->getfd4()<<p->next->stu->getfg5<<
         p->next->stu->geter6()<<endl;

}

void main()
{link_list qs;
qs.creat();
qs.find(head);
}
0 回复
1