.h文件
#if !defined __HEAD1__H__
#define __HEAD1__H__
#include
#include
#include
using namespace std;
class student{
public:
int GetNumber();
char *GetName();
char *GetClass();
float GetElec();
float GetC_prog();
float GetEng();
float GetMedia();
float GetMath();
float GetPolity();
float GetSport();
void input();
private:
int Number;
char class_0[20];
char Name[8];
float elec;
float c_prog;
float media;
float eng;
float math;
float sport;
float polity;
float Totalcent;
float Average;
};
int student::GetNumber()
{
return Number;
}
char *student::GetName()
{
return Name;
}
char *student::GetClass()
{
return class_0;
}
float student::GetElec()
{
return elec;
}
float student::GetC_prog()
{
return c_prog;
}
float student::GetEng()
{
return eng;
}
float student::GetMath()
{
return math;
}
float student::GetMedia()
{
return media;
}
float student::GetSport()
{
return sport;
}
float student::GetPolity()
{
return polity;
}
void student::input()
{
cout<<"学号:";
cin>>Number;
cout<<"姓名:";
cin>>Name;
cout<<"班级:";
cin>>class_0;
cout<<"电子技术:";
cin>>elec;
cout<<"C++ 程序设计:";
cin>>c_prog;
cout<<"多媒体技术:";
cin>>media;
cout<<"大学英语:";
cin>>eng;
cout<<"高等数学:";
cin>>math;
cout<<"大学体育:";
cin>>sport;
cout<<"马克思主义政治经济学:";
cin>>polity;
}
#endif
.C文件
#include
#include
#include
#include"1.h"
using namespace std;
int i=0,n=0;
float allscore[50];
student s[50];
void insert();
void delete1();
void find();
void xiugai();
void tongji();
void sort();
void input();
void output();
void contin()
{
cout<<"是否继续操作(y/n)";
char a; int j;
cin>>a;
while(a!='y'&&a!='n')
cin>>a;
if(a=='y')
{
cout<<"你想继续做什么:";
cin>>j;
while(!(j<=8&&j>=1))
{
cout<<"The number is too big or small,please input it again.";
cin>>j;
}
switch(j)
{
case 1:cout<<"1、按顺序输入若干个学生的信息"<
}
else if(a=='n') cout<<"操作结束!!!"<
void input()
{
cout<<"你想输入多少个学生信息:";
cin>>n;
for(i=0;i
s[i].input();
}
for(i=0;i
allscore[i]=s[i].GetElec()+s[i].GetElec()+s[i].GetMedia()+s[i].GetEng()+s[i].GetMath()+s[i].GetSport()+s[i].GetPolity();
}
contin();
}
void output()
{
if(n<=0)
{
cout<<"请先输入学生的信息,";
input();
}
cout<<"每位学生的信息分别为:"<
cout<
contin();
}
void insert()
{
if(n<=0)
{
cout<<"请先输入学生的信息,";
input();
}
cout<<"请输入你要插入的位置:";
int k;
cin>>k;
while(!(k>0&&k<=n))
{
cout<<"操作错误,请重新操作:";
cin>>k;
}
if(k<=n)
{
n++;
for(int i=n-1;i>=k;i--)
{
s[i]=s[i-1];
}
}
s[k-1].input();
contin();
}
void delete1()
{
if(n<=0)
{
cout<<"请先输入学生的信息,";
input();
}
cout<<"请输入你要删除的位置:";
int k;
cin>>k;
while(!(k>=0&&k
cout<<"你输入的位置不存在,请重新输入";
cin>>k;
}
for(i=k-1;i
s[i]=s[i+1];
}
n--;
contin();
}
void xiugai()
{
if(n<=0)
{
cout<<"请先输入学生的信息,";
input();
}
int num;
char c;
do{
cout<<"请输入需要修改的学生的学号:";
cin>>num;
for(int i=0;i
if(s[i].GetNumber()==num)
{
s[i].input();
}
else {cout<<"没有这个学生."<
cout<<"是否还要修改(y/n)";
cin>>c;
while(c!='y'&&c!='n')
cin>>c;
}while(c=='y');
contin();
}
void find()
{
if(n<=0)
{
cout<<"请先输入学生的信息,";
input();
}
char na[15];
cin>>na;
for(int i=0;i
if(strcmp(s[i].GetName(),na)==0)
{
cout<
else cout<<"没有这个学生."<
contin();
}
void tongji()
{
if(n<=0)
{
cout<<"请先输入学生的信息,";
input();
}
for(i=0;i
cout<<"各位学生的总分分别是";
for(i=0;i
cout<<"第"< }
contin();
}
void sort()
{
if(n<=0)
{
cout<<"请先输入学生的信息,";
input();
}
student temp;
for(i=0;i
temp=s[i];
s[i]=s[j];
s[j]=temp;
}
cout<<"已经排好序了,是否需要输出(y/n):";
char yn;
cin>>yn;
while(yn!='y'&&yn!='n')
{
cout<<"操作错误!!!请重新输入:";
cin>>yn;
}
if(yn=='y')
{
cout<<"所有学生的成绩按总分从高到低的排名是:"<
}
else contin();
}
int main()
{
cout<
cout<<"*";
cout<<" ***";
for(s=1;s<=30;s++)
cout<<"*";
cout<
int k;
cin>>k;
while((k<=0||k>9))
{
cout<<"The number is too big or small,please input it again.";
cin>>k;
}
switch(k)
{
case 1:cout<<"1、按顺序输入若干个学生的信息"<