小型学生成绩管理系统 (大一编程作业)

/*小型学生成绩管理系统*/
#include<bits/stdc++.h>
using namespace std;
typedef struct{
	int SID;
	int CID;
	char name[10];
	int chinese,math,english,code;
}Stu;
Stu student[50];
int t=0;
void print_menu(){
	cout<<"Welcome to Student Performance Management System (SPMS)."<<endl;
	cout<<"1 - Add"<<endl;
	cout<<"2 - Remove"<<endl;
	cout<<"3 - Query"<<endl;
	cout<<"4 - Show ranking"<<endl;
	cout<<"5 - Show Statistics"<<endl;
	cout<<"0 - Exit"<<endl;
}
void add(){
	cout<<"Please enter the SID, CID, name and four scores. Enter 0 to finish."<<endl;
	cin>>student[t].SID>>student[t].CID>>student[t].name;
	cin>>student[t].chinese>>student[t].math>>student[t].english>>student[t].code;
	t++;
}
void del(){
	cout<<"student removed"<<endl;
	t--;
}
void query(){	
}
void show_ranking(){
	cout<<"Showing the ranklist hurts students' self-esteem. Don't do that"<<endl;
	query();
	for(int i=0;i<t;i++){
		cout<<student[i].SID<<" "<<student[i].CID<<" "<<student[i].name<<" ";
		cout<<student[i].chinese<<" "<<student[i].math<<" "<<student[i].english<<" "<<student[i].code<<endl;
	}
}
void show_stat(){
	double chinese_average=0;
	double math_average=0;
	double english_average=0;
	double code_average=0;
	for(int i=0;i<t;i++){
		chinese_average+=student[i].chinese;
		math_average+=student[i].math;
		english_average+=student[i].english;
		code_average+=student[i].code;
	}
	cout<<"Chinese"<<endl;
	printf("Average Score: %.2f\n",chinese_average/t);
	cout<<"Math"<<endl;
	printf("Average Score: %.2f\n",math_average/t);
	cout<<"English"<<endl;
	printf("Average Score: %.2f\n",english_average/t);
	cout<<"Code"<<endl;
	printf("Average Score: %.2f\n",code_average/t);
}
int main(){
	while(true){
		int choice;
		print_menu();
		cin>>choice;
		if(choice==0)break;
		if(choice==1)add();
		if(choice==2)del();
		if(choice==3)query();
		if(choice==4)show_ranking();
		if(choice==5)show_stat();
	}
	return 0;
}
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值