简单的学生管理系统

制作一个简单的学生管理系统
用C++的类创建一个简单的学生管理系统:
#include<iostream>
#include<string>
using namespace std;

class student
{
public:
	int num;		//学号
	string name;	//姓名
	int Chinese;	//语文成绩
	int Math;		//数学成绩
	int English;	//英语成绩
	int Results;	//总成绩
	student *next;
};

int main(){
	cout << "请输入学生的 学号,姓名,语文成绩,数学成绩,英语成绩(空格隔开):" << endl;
	int S = 0;	//是平均成绩
	student *head;
	student S1;
	student S2;
	student S3;
	head = &S1;
	cin >>S1.num>>S1.name>>S1.Chinese>>S1.Math>>S1.English;
	S1.Results = S1.Chinese + S1.Math + S1.English;
	S1.next = &S2;
	cin >> S2.num>>S2.name>>S2.Chinese>>S2.Math>>S2.English;
	S2.Results = S2.Chinese + S2.Math + S2.English;
	S2.next = &S3;
	cin >> S3.num>>S3.name>>S3.Chinese>>S3.Math>>S3.English;
	S3.Results = S3.Chinese + S3.Math + S3.English;
	S3.next = NULL;
	S = S1.Results + S2.Results + S3.Results;
	S /= 3;
	cout << "三人总成绩的平均分是:" << S << endl;
	cout << "输入你要查找的学生学号:" << endl;
	int n;
	cin >> n;
	switch (n)
	{
	case 1:cout << "学号:" << S1.num << "\n" << "姓名:" << S1.name << "\n" << "语文成绩:" << S1.Chinese << "\n数学成绩:" << S1.Math << "\n英语成绩" << S1.English << "\nta的平均成绩:" << (S1.Chinese + S1.Math + S1.English)/3.0 << endl;
		break;
	case 2:cout << "学号:" << S2.num << "\n" << "姓名:" << S2.name << "\n" << "语文成绩:" << S2.Chinese << "\n数学成绩:" << S2.Math << "\n英语成绩" << S2.English << "\nta的平均成绩:" << (S2.Chinese + S2.Math + S2.English)/3.0 << endl;
		break;
	case 3:cout << "学号:" << S3.num << "\n" << "姓名:" << S3.name << "\n" << "语文成绩:" << S3.Chinese << "\n数学成绩:" << S3.Math << "\n英语成绩" << S3.English << "\nta的平均成绩:" << (S3.Chinese + S3.Math + S3.English)/3.0 << endl;
		break;
	default:cout <<"你输入的学号无效"<< endl;
		break;
	}
	cout << "您要对学生信息进行修改吗?(T or F):" << endl;
	char ch;
	cin >> ch;
	if (ch =='T')
	{
		cout << "请输入要修改的学生的学号" << endl;
		int i;
		cin >> i;
		switch (i)
		{
		case 1:cout <<"请输入:姓名 语文成绩 数学成绩 英语成绩"<< endl;
			cin >>S1.name >> S1.Chinese >> S1.Math >> S1.English;
			S1.Results = S1.Chinese + S1.Math + S1.English;
			   break;
		case 2:cout << "请输入 姓名 语文成绩 数学成绩 英语成绩" << endl;
			cin >>S2.name >> S2.Chinese >> S2.Math >> S2.English;
			S2.Results = S2.Chinese + S2.Math + S2.English;
			   break;
		case 3:cout << "请输入 姓名 语文成绩 数学成绩 英语成绩" << endl;
			cin >>S3.name >> S3.Chinese >> S3.Math >> S3.English;
			S3.Results = S3.Chinese + S3.Math + S3.English;
			   break;
		default:cout << "您输入的学号无效" << endl;
			break;
		}
	}
	else if (ch=='F')
	{
		cout << "谢谢使用!" << endl;
		exit(0);
	}
	else
	{
		cout <<"您输入了错误的字符,系统将在10秒后爆炸"<< endl;
		exit(0);
	}
	system("pause");
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值