设为首页收藏本站

新微赢技术网

 找回密码
 注册
搜索
热搜: 回贴
查看: 1683|回复: 0
打印 上一主题 下一主题

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

[复制链接]
跳转到指定楼层
1#
发表于 2009-11-3 03:30:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#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);
您需要登录后才可以回帖 登录 | 注册

本版积分规则

申请友链|小黑屋|最新主题|手机版|新微赢技术网 ( 苏ICP备08020429号 )  

GMT+8, 2024-11-18 13:47 , Processed in 0.108963 second(s), 10 queries , Gzip On, Memcache On.

Powered by xuexi

© 2001-2013 HaiAn.Com.Cn Inc. 寰耽

快速回复 返回顶部 返回列表