用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - c++代码库

研究生系统

2019-06-07 作者:灿灿举报

[c++]代码库

#include<iostream>
#include<fstream>
#include<string>
#include"graduatestudent.h"
#include "academicgraduatestudent.h"
#include "engineeringgraduatestudent.h"
using namespace std;
float engineeringgraduatestudent::sumengineeringscore=0.0;
int engineeringgraduatestudent::countengineeringnumber=0;
float academicgraduatestudent::sumacademicscore=0.0;
int engineeringgraduatestudent::b[6]={0,0,0,0,0,0};
int academicgraduatestudent::countacademicnumber=0;
int academicgraduatestudent::a[6]={0,0,0,0,0,0};
istream& operator>>(istream& input,academicgraduatestudent& academic)
{cout<<"学号:";input>>academic.num;
cout<<"姓名:"; 
input>>academic.name;
cout<<"性别:";input>>academic.sex;
cout<<"年龄:";input>>academic.age;
cout<<"课程成绩:";input>>academic.coursescore;
cout<<"专业:";input>>academic.major;
cout<<"论文篇数:";input>>academic.papernumber;
if(academic.papernumber>=1)
  {cout<<"论文1名称:";
  input>>academic.apaper.paper1;
  cout<<"论文1级别(选择1,2,3):" ;
  input>>academic.apaper.paperlevel1;
  academic.paperscore=academic.apaper.paperlevel1*10;
  }
if(academic.papernumber>=2)
  {cout<<"论文2名称:";
  input>>academic.apaper.paper2;
  cout<<"论文2级别(选择1,2,3):";
  input>>academic.apaper.paperlevel2;
  academic.paperscore=academic.paperscore+academic.apaper.paperlevel2*10;
  }  
if(academic.papernumber>=3)
  {cout<<"论文3名称:";
  input>>academic.apaper.paper3;
  cout<<"论文3级别(选择1,2,3):";
  input>>academic.apaper.paperlevel3;
  academic.paperscore=academic.paperscore+academic.apaper.paperlevel3*10;
  } 
  academic.sumscore=academic.paperscore*0.3+academic.coursescore*0.7;
  if(academic.sumscore==100.0) {academicgraduatestudent::a[0]++;}
  if(academic.sumscore<100.0&&academic.sumscore>=90.0){academicgraduatestudent::a[1]++;} 
  if(academic.sumscore<90.0&&academic.sumscore>=80.0){academicgraduatestudent::a[2]++;} 
  if(academic.sumscore<80.0&&academic.sumscore>=70.0){academicgraduatestudent::a[3]++;} 
  if(academic.sumscore<70.0&&academic.sumscore>=60.0){academicgraduatestudent::a[4]++;} 
  if(academic.sumscore<60.0&&academic.sumscore>=0.0){academicgraduatestudent::a[5]++;} 
  academicgraduatestudent::sumacademicscore=academicgraduatestudent::sumacademicscore+academic.sumscore;
academicgraduatestudent::countacademicnumber=academicgraduatestudent::countacademicnumber+1;
  return input;
}
void show()
{ cout<<"总分:";
cout<< academicgraduatestudent::sumacademicscore<<endl;
cout<<"平均分:";
cout<<academicgraduatestudent::sumacademicscore/academicgraduatestudent::countacademicnumber<<endl;
cout<<"分数:满分人数:"<<academicgraduatestudent::a[0]<<"占比:"<<academicgraduatestudent::a[0]*100/(academicgraduatestudent::a[0]+academicgraduatestudent::a[1]+academicgraduatestudent::a[2]+academicgraduatestudent::a[3]+academicgraduatestudent::a[4]+academicgraduatestudent::a[5])<<"%"<<endl; 
cout<<"分数:90-100人数:"<<academicgraduatestudent::a[1]<<"占比:"<<academicgraduatestudent::a[1]*100/(academicgraduatestudent::a[0]+academicgraduatestudent::a[1]+academicgraduatestudent::a[2]+academicgraduatestudent::a[3]+academicgraduatestudent::a[4]+academicgraduatestudent::a[5])<<"%"<<endl;  
cout<<"分数:80-90人数:"<<academicgraduatestudent::a[2]<<"占比:"<<academicgraduatestudent::a[2]*100/(academicgraduatestudent::a[0]+academicgraduatestudent::a[1]+academicgraduatestudent::a[2]+academicgraduatestudent::a[3]+academicgraduatestudent::a[4]+academicgraduatestudent::a[5])<<"%"<<endl; 
cout<<"分数:70-80人数:"<<academicgraduatestudent::a[3]<<"占比:"<<academicgraduatestudent::a[3]*100/(academicgraduatestudent::a[0]+academicgraduatestudent::a[1]+academicgraduatestudent::a[2]+academicgraduatestudent::a[3]+academicgraduatestudent::a[4]+academicgraduatestudent::a[5])<<"%"<<endl;  
cout<<"分数:60-70人数:"<<academicgraduatestudent::a[4]<<"占比:"<<academicgraduatestudent::a[4]*100/(academicgraduatestudent::a[0]+academicgraduatestudent::a[1]+academicgraduatestudent::a[2]+academicgraduatestudent::a[3]+academicgraduatestudent::a[4]+academicgraduatestudent::a[5])<<"%"<<endl; 
cout<<"分数:不及格人数:"<<academicgraduatestudent::a[5]<<"占比:"<<academicgraduatestudent::a[5]*100/(academicgraduatestudent::a[0]+academicgraduatestudent::a[1]+academicgraduatestudent::a[2]+academicgraduatestudent::a[3]+academicgraduatestudent::a[4]+academicgraduatestudent::a[5])<<"%"<<endl;  
}
ostream& operator<<(ostream& output,academicgraduatestudent& academic)
{output<<"学号:"<<academic.num<<" 姓名:"<<academic.name<<" 性别:"<<academic.sex<<" 年龄:"<<academic.age<<" 课程成绩:"<<academic.coursescore<<" 专业:"<<academic.major<<endl;
output<<"论文成绩:"<<academic.paperscore<<"总成绩:"<<academic.sumscore;
return output;
}
 istream &operator >>(istream&in,engineeringgraduatestudent&engineering)
{cout<<"学号:";in>>engineering.num;
cout<<"姓名:"; 
in>>engineering.name;
cout<<"性别:";in>>engineering.sex;
cout<<"年龄:";in>>engineering.age;
cout<<"课程成绩:";in>>engineering.coursescore;
cout<<"领域:";in>>engineering.field;
cout<<"项目名称:"; 
in>>engineering.aproject.pname;
cout<<"项目级别(A,B,C):";
in>>engineering.aproject.plevel;
if(engineering.aproject.plevel=='A')
{engineering.projectscore=90;
}
if(engineering.aproject.plevel=='B')
{engineering.projectscore=75;
}
if(engineering.aproject.plevel=='C')
{engineering.projectscore=60;
}
engineering.sumscore=engineering.coursescore*0.5+engineering.projectscore*0.5;
if(engineering.sumscore==100.0) {engineeringgraduatestudent::b[0]++;}
  if(engineering.sumscore<100.0&&engineering.sumscore>=90.0){engineeringgraduatestudent::b[1]++;} 
  if(engineering.sumscore<90.0&&engineering.sumscore>=80.0){engineeringgraduatestudent::b[2]++;} 
  if(engineering.sumscore<80.0&&engineering.sumscore>=70.0){engineeringgraduatestudent::b[3]++;} 
  if(engineering.sumscore<70.0&&engineering.sumscore>=60.0){engineeringgraduatestudent::b[4]++;} 
  if(engineering.sumscore<60.0&&engineering.sumscore>=0.0){engineeringgraduatestudent::b[5]++;} 
 engineeringgraduatestudent::countengineeringnumber= engineeringgraduatestudent::countengineeringnumber+1;
 engineeringgraduatestudent::sumengineeringscore=engineeringgraduatestudent::sumengineeringscore+engineering.sumscore;
return in;
}
ostream& operator<<(ostream& out,engineeringgraduatestudent& engineering)
{out<<"学号:"<<engineering.num<<" 姓名:"<<engineering.name<<" 性别:"<<engineering.sex<<" 年龄:"<<engineering.age<<" 课程成绩:"<<engineering.coursescore<<" 领域:"<<engineering.field<<endl;
out<<"项目成绩:";out<<engineering.projectscore<<"总成绩:"<<engineering.sumscore;
return out;
}
int w=0;
void save_to_file()
{ofstream outfile("f2.dat",ios::out);
if(!outfile)
 {cerr<<"open f2.dat error!"<<endl;
 exit(1);
 }
 academicgraduatestudent a[100];
loop: 
 cin>>a[w];
 cout<<a[w];
  outfile<<a[w]<<endl;
 cout<<endl;
 cout<<"是否继续录入(yes no):";
  string ming;
  cin>>ming;
  if(ming=="yes") {w=w+1;
  goto loop;}
  if(ming=="no")
  {cout<<"返回菜单"<<endl;
  }
 outfile.close();
}
void add()
{int j=0;
	ofstream outfile("f2.dat",ios::out|ios::app);
	academicgraduatestudent a[100];
	loop: 
 cin>>a[j];
 cout<<a[j];
  outfile<<a[j]<<endl;
 cout<<endl;
 cout<<"是否继续录入(yes no):";
  string ming;
  cin>>ming;
  if(ming=="yes") {j=j+1;
  goto loop;}
  if(ming=="no")
  {cout<<"返回菜单"<<endl;
  }
 outfile.close();
}
void searchacademicgraduatestudent()
{ifstream infile("f2.dat",ios::in);
if(!infile)
{cerr<<"open error!"<<endl;
exit(1);
}
char ch;
while(infile.get(ch))
{cout<<ch;
}
infile.close();
}
void save1_to_file()
{ofstream outfile("f1.dat",ios::out);
if(!outfile)
 {cerr<<"open f1.dat error!"<<endl;
 exit(1);
 }
 int j=0;
 engineeringgraduatestudent b[100];
loop: 
 cin>>b[j];
 cout<<b[j];
 outfile<<b[j];
 cout<<endl;
 cout<<"是否继续录入(yes no):";
  string wo;
  cin>>wo;
  if(wo=="yes") {j=j+1;
  goto loop;}
  if(wo=="no")
  {cout<<"返回菜单"<<endl; 
  }
 outfile.close();
}
void searchengineeringgraduatestudent()
{
	ifstream infile("f1.dat",ios::in);
if(!infile)
{cerr<<"open error!"<<endl;
exit(1);
}
char ch;
while(infile.get(ch))
{cout<<ch;
}
infile.close();
}
void show1()
{cout<<"总分:";
cout<< engineeringgraduatestudent::sumengineeringscore<<endl;
cout<<"平均分:";
cout<<engineeringgraduatestudent::sumengineeringscore/engineeringgraduatestudent::countengineeringnumber<<endl;
cout<<"分数:满分人数:"<<engineeringgraduatestudent::b[0]<<"占比:"<<(engineeringgraduatestudent::b[0]*100/(engineeringgraduatestudent::b[0]+engineeringgraduatestudent::b[1]+engineeringgraduatestudent::b[2]+engineeringgraduatestudent::b[3]+engineeringgraduatestudent::b[4]+engineeringgraduatestudent::b[5]))<<"%"<<endl; 
cout<<"分数:90-100人数:"<<engineeringgraduatestudent::b[1]<<"占比:"<<(engineeringgraduatestudent::b[1]*100/(engineeringgraduatestudent::b[0]+engineeringgraduatestudent::b[1]+engineeringgraduatestudent::b[2]+engineeringgraduatestudent::b[3]+engineeringgraduatestudent::b[4]+engineeringgraduatestudent::b[5]))<<"%"<<endl; 
cout<<"分数:80-90人数:"<<engineeringgraduatestudent::b[2]<<"占比:"<<(engineeringgraduatestudent::b[2]*100/(engineeringgraduatestudent::b[0]+engineeringgraduatestudent::b[1]+engineeringgraduatestudent::b[2]+engineeringgraduatestudent::b[3]+engineeringgraduatestudent::b[4]+engineeringgraduatestudent::b[5]))<<"%"<<endl; 
cout<<"分数:70-80人数:"<<engineeringgraduatestudent::b[3]<<"占比:"<<(engineeringgraduatestudent::b[3]*100/(engineeringgraduatestudent::b[0]+engineeringgraduatestudent::b[1]+engineeringgraduatestudent::b[2]+engineeringgraduatestudent::b[3]+engineeringgraduatestudent::b[4]+engineeringgraduatestudent::b[5]))<<"%"<<endl; 
cout<<"分数:60-70人数:"<<engineeringgraduatestudent::b[4]<<"占比:"<<(engineeringgraduatestudent::b[4]*100/(engineeringgraduatestudent::b[0]+engineeringgraduatestudent::b[1]+engineeringgraduatestudent::b[2]+engineeringgraduatestudent::b[3]+engineeringgraduatestudent::b[4]+engineeringgraduatestudent::b[5]))<<"%"<<endl; 
cout<<"分数:不及格人数:"<<engineeringgraduatestudent::b[5]<<"占比:"<<(engineeringgraduatestudent::b[5]*100/(engineeringgraduatestudent::b[0]+engineeringgraduatestudent::b[1]+engineeringgraduatestudent::b[2]+engineeringgraduatestudent::b[3]+engineeringgraduatestudent::b[4]+engineeringgraduatestudent::b[5]))<<"%"<<endl; 
}
void add1()
{
	int j=0;
	ofstream outfile("f1.dat",ios::out|ios::app);
	engineeringgraduatestudent b[100];
	loop: 
 cin>>b[j];
 cout<<b[j];
  outfile<<b[j]<<endl;
 cout<<endl;
 cout<<"是否继续录入(yes no):";
  string ming;
  cin>>ming;
  if(ming=="yes") {j=j+1;
  goto loop;}
  if(ming=="no")
  {cout<<"返回菜单"<<endl;
  }
 outfile.close();
}
void menu()
{cout<<"                   研究生成绩管理系统               "<<endl;
loopen:
cout<<"选择操作类型(1.文件读入2.成绩统计3.文件保存4.退出系统5.查询功能6.增加输入): ";
int a;
cin>>a; 
if(a==1) 
{loop:
cout<<"请选择研究生类型:(学术硕士or工程硕士)"<<endl;
string type;
cin>>type;
if(type=="学术硕士")
  { save_to_file();
  goto loopen;
  }
  if(type=="工程硕士")  
   { save1_to_file();
   goto loopen;
   }
}
if(a==2)
{cout<<"查看类型(学术硕士)(工程硕士):";
string leixing;
cin>>leixing;
if(leixing=="学术硕士"){ 
show();goto loopen;}
if(leixing=="工程硕士"){show1();goto loopen;} 
} 
if(a==3){cout<<"文件已保存"<<endl; 
}
if(a==4) {cout<<"正在退出系统"<<endl; 
}
if(a==5){searchacademicgraduatest

[源代码打包下载]




分享到:
更多

网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。