本文主要是介绍c++学生系统(gezhengxu2024独创),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
前言:实在懒得用vector了,所以没有删除学生,等破300粉丝我就加删除学生。(还有亿些问题)
=========================================================================
#include<bits/stdc++.h>
#include<conio.h>
using namespace std;
string xue[5001],xingbie[5001];
long int xuehao[5001],jifen[5001],zhan=0;
int read()
{char ch=_getch();while(ch>'9'||ch<'0') ch=_getch();return ch-48;
}
void Read(){ifstream in("学生档案.txt");in>>zhan;for(int i=1;i<=5000;i++) in>>xue[i]>>xingbie[i]>>xuehao[i]>>jifen[i];in.close();}
void Save(){ofstream out("学生档案.txt");out<<zhan<<"\n";for(int i=1;i<=5000;i++) out<<xue[i]<<" "<<xingbie[i]<<" "<<xuehao[i]<<" "<<jifen[i]<<"\n";out.close();}
void paijifen(){for(int i=1;i<=zhan-1;i++){for(int j=1;j<=zhan-i;j++){if(jifen[j]<jifen[j+1]){swap(jifen[j],jifen[j+1]);swap(xuehao[j],xuehao[j+1]);swap(xingbie[j],xingbie[j+1]);swap(xue[j],xue[j+1]);}}}for(int i=1;i<=zhan;i++){cout<<"积分:"<<jifen[i]<<" 学号:"<<xuehao[i]<<" 性别:"<<string(xingbie[i])<<" 姓名:"<<string(xue[i])<<endl;}system("pause");system("cls");
}
void paixuehao(){for(int i=1;i<=zhan-1;i++){for(int j=1;j<=zhan-i;j++){if(xuehao[j]>xuehao[j+1]){swap(jifen[j],jifen[j+1]);swap(xuehao[j],xuehao[j+1]);swap(xingbie[j],xingbie[j+1]);swap(xue[j],xue[j+1]);}} }for(int i=1;i<=zhan;i++){cout<<"学号:"<<xuehao[i]<<" 积分:"<<jifen[i]<<" 性别:"<<string(xingbie[i])<<" 姓名:"<<string(xue[i])<<endl;}system("pause");system("cls");
}
int main()
{Read(); while(1){Read();system("cls");cout<<"gezhengxu2024出品====================================教师使用系统====================================gezhengxu2024出品\n";printf("1:添加学生(删除在学生档案中自己手动删)\n2:学号排序\n3:积分排序\n4:添加积分\n5:减去积分\n6:查找学号\n7:课后评价\n8:退出\n");long int s;cin>>s;system("cls");else if(s==5){if(zhan==0) {cout<<"你没学生!!!!!";system("pause");continue; }cout<<"1:学号减去\n2:姓名减去\n";long int jinitaimei;cin>>jinitaimei;if(jinitaimei==1){cout<<"请输入学号和要减去的积分:\n";long int xh,jf;cin>>xh>>jf;for(int i=1;i<=zhan;i++){if(xuehao[i]==xh){jifen[i]-=jf;cout<<"减去成功!";Save();system("pause");continue; }}}else if(jinitaimei==2){cout<<"请输入姓名和要减去的积分:\n";long int jf;string xm;cin>>xm>>jf; for(int i=1;i<=zhan;i++){if(xue[i]==xm){jifen[i]+=jf;cout<<"减去成功!"; Save();system("pause");continue; }}}}if(s==7){if(zhan==0) {cout<<"你没学生!!!!!";system("pause");continue; }cout<<"1:学号添加\n2:姓名添加\n";long int jinitaimei;cin>>jinitaimei;if(jinitaimei==1){cout<<"请输入学号:\n";long int xh;cin>>xh;int c,d,e,f,g,h,z=0;printf("学习态度:");c=read();printf("\n知识掌握:");d=read();printf("\n应用测评:");e=read();printf("\n座位整洁:");g=read();printf("\n签到:");f=read();if(f==3){z+=30;Save();}else if(f==2){z+=10;Save();}else if(f==1){z+=0;Save();}if(g==5){z+=10;Save();}h=c+d+e;h/=3;if(h==5){z+=50;Save();}else if(h==4){z+=10;Save();}else if(h<=3){z+=0;Save();}for(int i=1;i<=zhan;i++){if(xuehao[i]==xh){jifen[i]+=z;cout<<"添加成功!";Save();system("pause");continue; }}}else if(jinitaimei==2){cout<<"请输入姓名:\n";string xm;cin>>xm; int c,d,e,f,g,h,z=0;printf("学习态度:");c=read();printf("\n知识掌握:");d=read();printf("\n应用测评:");e=read();printf("\n座位整洁:");g=read();printf("\n签到:");f=read();if(f==3){z+=30;Save();}else if(f==2){z+=10;Save();}else if(f==1){z+=0;Save();}if(g==5){z+=10;Save();}h=c+d+e;h/=3;if(h==5){z+=50;Save();}else if(h==4){z+=10;Save();}else if(h<=3){z+=0;Save();}for(int i=1;i<=zhan;i++){if(xue[i]==xm){jifen[i]+=z;cout<<"添加成功!"; Save();system("pause");continue; }}}else{printf("无用数字!");system("pause");continue; }}else if(s==8){printf("退出成功!");Save();return 0; }else if(s==1){if(zhan==5000){printf("学生已到5000人极限,无法添加!");system("pause");continue; }zhan+=1;cout<<"请输入姓名:";cin>>xue[zhan];cout<<"请输入性别:";cin>>xingbie[zhan];cout<<"请输入学号:";cin>>xuehao[zhan];Save();}else if(s==2){if(zhan==0) {cout<<"你没学生!!!!!";system("pause");continue; }else if(zhan==1){cout<<"你就一个,排什么排!!!!!!";system("pause");continue; }paixuehao();}else if(s==3){if(zhan==0) {cout<<"你没学生!!!!!";system("pause");continue; }else if(zhan==1){cout<<"你就一个,排什么排!!!!!!";system("pause");continue; }paijifen();}else if(s==4){if(zhan==0) {cout<<"你没学生!!!!!";system("pause");continue; }cout<<"1:学号添加\n2:姓名添加\n";long int jinitaimei;cin>>jinitaimei;if(jinitaimei==1){cout<<"请输入学号和要添加的积分:\n";long int xh,jf;cin>>xh>>jf;for(int i=1;i<=zhan;i++){if(xuehao[i]==xh){jifen[i]+=jf;cout<<"添加成功!";Save();system("pause");continue; }}}else if(jinitaimei==2){cout<<"请输入姓名和要添加的积分:\n";long int jf;string xm;cin>>xm>>jf; for(int i=1;i<=zhan;i++){if(xue[i]==xm){jifen[i]+=jf;cout<<"添加成功!"; Save();system("pause");continue; }}}else{printf("无用数字!");system("pause");continue; }}else if(s==6){if(zhan==0) {cout<<"你没学生!!!!!";system("pause");continue; }cout<<"请输入姓名:";string xm;cin>>xm;for(int i=1;i<=zhan;i++){if(xue[i]==xm) cout<<xuehao[i]<<endl;system("pause");continue; }}else{printf("无用数字!");}}Save();return 0;}
这篇关于c++学生系统(gezhengxu2024独创)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!