#include<fstream>
#include<string>
#include<iomanip>
#include<stdlib.h>
using namespace std;
#define MAX1 100
#define MAX2 150
class Postgraduate
{
public:
char name[10]; //考生姓名
int number; //准考证号
string major; //报考专业
char state[10]; //应届历届
int MathScore;//数学成绩
int EnglishScore;//英语成绩
int PoliticalScore;//政治成绩
int BasisScore;//专业基础课成绩
int sumscore;// 总分
int n;
int add(){ //定义计算总分的函数
sumscore=MathScore+EnglishScore+PoliticalScore+BasisScore;
return(sumscore);}
Postgraduate(){};//析构函数
Postgraduate(char *nam,char* stat,int num,string maj,int Math,int English,int Political,int Basis){//构造函数
strcpy(name,nam);
strcpy(state,stat);
number=num;
major=maj;
MathScore=Math;
EnglishScore=English;
PoliticalScore=Political;
BasisScore=Basis;
};
void output()//输出考生的信息
{
cout<<"研究生姓名:"<<name ;
cout<<"准考证号:"<<number ;
cout<<"报考专业:"<<major ;
cout<<"是否应届:"<<state ;
cout<<"数学成绩:"<<MathScore ;
cout<<"外语成绩:"<<EnglishScore ;
cout<<"政治成绩:"<<PoliticalScore ;
cout<<"专业课成绩:"<<BasisScore;
cout<<endl;
}
Postgraduate & operator=(Postgraduate& s) //对=运算符进行重载
{
strcpy(name,s.name);
major=s.major;
number=s.number;
MathScore=s.MathScore;
EnglishScore=s.EnglishScore;
PoliticalScore=s.PoliticalScore;
BasisScore=s.BasisScore;
return *this;
}
};
class condition //录取条件类
{
public:
string majorquire;
int MathRequire,EnglishRequire,PoliticalRequire,BasisRequire,sumscore,orz;
condition() //无参的构造函数
{
cout<<"请输入录取专业:";
cin>>majorquire;
cout<<"请依次输入录取的数学、外语、政治、专业课及总分要求:"<<endl;//输入各个学科的最低分数要求
cout<<"数学:";
cin>>MathRequire;
cout<<"外语:";
cin>>EnglishRequire;
cout<<"政治:";
cin>>PoliticalRequire;
cout<<"专业课:";
cin>>BasisRequire;
cout<<"总分:";
cin>>sumscore;
cout<<endl;
}
};
void getinfor()
{//输入研究生信息
cout<<"\t\t\t研究生初试录取系统\n";
cout<<"请输入报考研究生人数:";
int n;
cin>>n;
Postgraduate *a=new Postgraduate[n];
cout<<endl;
cout<<"请输入初试考生的信息!"<<endl;
for(int k=0;k<n;k++)
{
cout<<"请输入考生姓名"<<endl;
cin>>a[k].name;
cout<<"请输入准考证号:"<<endl;
cin>>a[k].number;
cout<<"请输入报考专业:"<<endl;
cin>>a[k].major;
cout<<"输入是否应届(请输入“是”或“否”):"<<endl;
cin>>a[k].state;
cout<<"请输入数学成绩:"<<endl;
cin>>a[k].MathScore;
cout<<"请输入外语成绩:"<<endl;
cin>>a[k].EnglishScore;
cout<<"请输入政治成绩:"<<endl;
cin>>a[k].PoliticalScore;
cout<<"请输入专业基础课成绩:"<<endl;
cin>>a[k].BasisScore;
};
cout<<"请输入录取要求"<<endl;
condition c;
fstream file1,file2;
file1.open("D:\\初试考生信息.txt",ios::out); //将考生信息写入文件中
file1<<"\t\t\t***********初试考生信息***********"<<endl;
file1<<"考生姓名 准考证号 报考专业 应届(Y)/历届(L) 数学 外语 政治 专业课 总分"<<endl;
for(int i=0;i<n;i++)
{
file1<<setw(8)<<a[i].name<<setw(9)<<a[i].number<<setw(12)<<a[i].major
<<setw(10)<<a[i].state<<setw(12)<<a[i].MathScore<<setw(6)<<a[i].EnglishScore
<<setw(6)<<a[i].PoliticalScore<<setw(7)<<a[i].BasisScore<<setw(8)<<a[i].add()<<endl;
}
file1.close();
Postgraduate g;
file2.open("D:\\考生初试结果信息.txt",ios::out); //将考生的录取信息写入文件中
file2<<"\t\t\t***********考生初试通过结果***********"<<endl;
file2<<"考生姓名 准考证号 报考专业 应届(Y)/历届(L) 数学 外语 政治 专业课 总分"<<endl;
for(i=0;i<n;i++)
{
if((a[i].major==c.majorquire)&&(a[i].add()>=c.sumscore)&&(a[i].MathScore>=c.MathRequire)&&(a[i].EnglishScore>=c.EnglishRequire)
&&(a[i].PoliticalScore>=c.PoliticalRequire)&&(a[i].BasisScore>=c.BasisRequire))
{
file2<<"初试合格的考生:"<<endl;
file2<<setw(8)<<a[i].name<<setw(9)<<a[i].number<<setw(12)<<a[i].major<<setw(10)<<a[i].state<<setw(12)
<<a[i].MathScore<<setw(6)<<a[i].EnglishScore<<setw(6)<<a[i].PoliticalScore<<setw(7)<<a[i].BasisScore<<setw(8)<<a[i].add()<<endl;
}
else
{
file2<<"初试不合格的考生:"<<endl;
file2<<setw(8)<<a[i].name<<setw(9)<<a[i].number<<setw(12)<<a[i].major<<setw(10)<<a[i].state<<setw(12)<<a[i].MathScore<<setw(6)<<a[i].EnglishScore<<
setw(6)<<a[i].PoliticalScore<<setw(7)<<a[i].BasisScore<<setw(8)<<a[i].add()<<endl;
}
}
file2.close();
}
void outtoend()//输出文件
{
std::ifstream _if("D:\\考生初试结果信息.txt");
for(std::string buf; std::getline(_if, buf); )
std::cout << buf << std::endl;
}
void getinfor2()
{//输入研究生信息
cout<<"\t\t\t研究生复试录取系统\n";
cout<<"请输入复试人数:";
int n;
cin>>n;
Postgraduate *a=new Postgraduate[n];
cout<<endl;
cout<<"请输入进行复试考生的信息!"<<endl;
for(int k=0;k<n;k++)
{
cout<<"请输入考生姓名"<<endl;
cin>>a[k].name;
cout<<"请输入准考证号:"<<endl;
cin>>a[k].number;
cout<<"请输入报考专业:"<<endl;
cin>>a[k].major;
cout<<"输入是否应届(请输入“是”或“否”):"<<endl;
cin>>a[k].state;
cout<<"请输入数学成绩:"<<endl;
cin>>a[k].MathScore;
cout<<"请输入外语成绩:"<<endl;
cin>>a[k].EnglishScore;
cout<<"请输入政治成绩:"<<endl;
cin>>a[k].PoliticalScore;
cout<<"请输入专业基础课成绩:"<<endl;
cin>>a[k].BasisScore;
};
int e,r;
cout<<"复试的总分要求:"<<endl;
cin>>e;
cout<<"复试的专业课要求:"<<endl;
cin>>r;
fstream file1,file2;
file1.open("D:\\复试考生信息.txt",ios::out); //将考生信息写入文件中
file1<<"\t\t\t***********复试考生信息***********"<<endl;
file1<<"考生姓名 准考证号 报考专业 应届(Y)/历届(L) 数学 外语 政治 专业课 总分"<<endl;
for(int i=0;i<n;i++)
{
file1<<setw(8)<<a[i].name<<setw(9)<<a[i].number<<setw(12)<<a[i].major
<<setw(10)<<a[i].state<<setw(12)<<a[i].MathScore<<setw(6)<<a[i].EnglishScore
<<setw(6)<<a[i].PoliticalScore<<setw(7)<<a[i].BasisScore<<setw(8)<<a[i].add()<<endl;
}
file1.close();
Postgraduate g;
int j;
for(int p=0;p<n;p++)//将考生按总分从高到低排序
{
for(int q=p;q<n;q++)
{
j=p;
if(a[q].add()>a[j].add())
j=q;
}
g=a[p];
a[p]=a[j];
a[j]=a[p];
}
file2.open("D:\\考生复试录取信息.txt",ios::out); //将考生的录取信息写入文件中
file2<<"\t\t\t***********考生复试录取结果***********"<<endl;
file2<<"考生姓名 准考证号 报考专业 应届(Y)/历届(L) 数学 外语 政治 专业课 总分"<<endl;
for(i=0;i<n;i++)
{
if((a[i].add()>=e)&&(a[i].BasisScore>=r))
{
file2<<"复试合格的考生:"<<endl;
file2<<setw(8)<<a[i].name<<setw(9)<<a[i].number<<setw(12)<<a[i].major<<setw(10)<<a[i].state<<setw(12)<<a[i].MathScore<<setw(6)<<a[i].EnglishScore<<
setw(6)<<a[i].PoliticalScore<<setw(7)<<a[i].BasisScore<<setw(8)<<a[i].add()<<endl;
}
else
{
file2<<"复试不合格的考生:"<<endl;
file2<<setw(8)<<a[i].name<<setw(9)<<a[i].number<<setw(12)<<a[i].major<<setw(10)<<a[i].state<<setw(12)<<a[i].MathScore<<setw(6)<<a[i].EnglishScore<<
setw(6)<<a[i].PoliticalScore<<setw(7)<<a[i].BasisScore<<setw(8)<<a[i].add()<<endl;
}
}
file2.close();
}
void outtoend2()//输出文件
{
std::ifstream _if("D:\\考生复试录取信息.txt");
for(std::string buf; std::getline(_if, buf); )
std::cout << buf << std::endl;
}
int main(){
static int j=0;// 统计录取的人数
int w,z;
do
{
cout<<"==========研究生录取系统=========="<<endl;
cout<<endl;
cout<<"根据菜单选择所需功能:"<<endl;
cout<<" 1. 输入初试考生信息 "<<endl;
cout<<" 2. 查看通过初试考生信息 "<<endl;
cout<<" 3. 输入考生复试信息 "<<endl;
cout<<" 4. 查看通过复试考生信息 "<<endl;
cout<<"======================================"<<endl;
cout<<"请输入您的选择:"<<endl;
cin>>w;
switch(w)
{
case 1:
system("cls");
getinfor();
break;
case 2:
system("cls");
outtoend();
break;
case 3:
system("cls");
getinfor2();
break;
case 4:
system("cls");
outtoend2();
break;
}
cout<<"返回上级菜单请输入1:"<<endl;
cin>>z;
system("cls");
}while(z==1);
return 0;
};
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)