基础的很简单的学生管理系统!!

#define _CRT_SECURE_NO_WARNINGS
#include
#include
using namespace std;
int f, g, h, m, n;
string r;
class Student{
public:
	class Student *next;   //环指针
	int i;			//学号
	string j;     //姓名
	int a;       //5课成绩
	int b;
	int c;
	void show(int o){
		switch (o){
		case 1:
			cout << "学号:" << p1.i << "姓名:" << p1.j << "语文成绩:" << p1.a << "英语成绩:" << p1.b << "数学成绩:" << p1.c << "他的总成绩" << p1.a+p1.b+p1.c<< endl;
			break;
		case 2:
			cout << "学号:" << p2.i << "姓名:" << p2.j << "语文成绩:" << p2.a << "英语成绩:" << p2.b << "数学成绩:" << p2.c << "他的总成绩" << p2.a + p2.b + p2.c << endl;
			break;
		case 3:
			cout << "学号:" << p3.i << "姓名:" << p3.j << "语文成绩:" << p3.a << "英语成绩:" << p3.b << "数学成绩:" << p3.c << "他的总成绩" << p3.a + p3.b + p3.c << endl;
			break;
		case 4:
			cout << "学号:" << p4.i << "姓名:" << p4.j << "语文成绩:" << p4.a << "英语成绩:" << p4.b << "数学成绩:" << p4.c << "他的总成绩" << p4.a + p4.b + p4.c << endl;
			break;
		}
	}
	void xg(int l){
		if (l == 1){
			cout << "输入想要修改的学号" << endl;
			cin >> n;
			if (n == p1.i){
				cout << "正在修改,请输入他的信息"<> p1.i;
				cout << "姓名";
				cin >> p1.j;
				cout << "语文成绩";
				cin >> p1.a;
				cout << "英语成绩";
				cin >> p1.b;
				cout << "数学成绩";
				cin >> p1.c;
			}
			else if (n == p2.i){
				cout << "正在修改,请输入他的信息" << endl;
				cout << "学号";
				cin >> p2.i;
				cout << "姓名";
				cin >> p2.j; 
				cout << "语文成绩";
				cin >> p2.a;
				cout << "英语成绩";
				cin >> p2.b;
				cout << "数学成绩";
				cin >> p2.c;
			}
			else if (n == p3.i){
				cout << "正在修改,请输入他的信息" << endl; 
				cout << "学号";
				cin >> p3.i; 
				cout << "姓名";
				cin >> p3.j; 
				cout << "语文成绩";
				cin >> p3.a; 
				cout << "英语成绩";
				cin >> p3.b;
				cout << "数学成绩";
				cin >> p3.c;
			}
			else if (n == p4.i){
				cout << "正在修改,请输入他的信息" << endl;
				cout << "学号";
				cin >> p4.i; 
				cout << "姓名";
				cin >> p4.j;
				cout << "语文成绩";
				cin >> p4.a; 
				cout << "英语成绩";
				cin >> p4.b;
				cout << "数学成绩";
				cin >> p4.c;
			}
		}
	}
}p1, p2, p3, p4;
void main(){
	int q[10] = { 0 }, w[10] = { 0 }, t[10] = {0};
	int *k=NULL;
	Student *p = new Student();
	class Student *head = NULL;         //头指针
	cout << "按顺序入4个学号:"<> p1.i;
	cin >> p2.i;
	cin >> p3.i;
	cin >> p4.i;
	cout<<"按顺序输入4个姓名:"<> p1.j;
	cin >> p2.j; 
	cin >> p3.j;
	cin >> p4.j;
	cout << "按顺序输入语文成绩:" << endl;
	cin >> p1.a;
	cin >> p2.a;
	cin >> p3.a;
	cin >> p4.a;
	cout << "按顺序输入英语成绩:" << endl;
	cin >> p1.b;
	cin >> p2.b;
	cin >> p3.b;
	cin >> p4.b;
	cout << "按顺序输入数学成绩:" << endl;
	cin >> p1.c;
	cin >> p2.c;
	cin >> p3.c;
	cin >> p4.c;
	head = &p1;
	p1.next = &p2;
	p2.next = &p3;
	p3.next = &p4;
	p4.next = NULL;
	cout << "学号列表" << endl;
	while (head != NULL){
		cout << head->i << endl;
		head = head->next;
	}
	head = &p1;
	cout << "姓名列表" << endl;
	while (head != NULL){
		cout << head->j << endl;
		head = head->next;
	}
	head = &p1;
	cout << "语文成绩列表" << endl;
	while (head != NULL){
		cout << head->a << endl;
		head = head->next;
	}
	head = &p1;
	q[0] = p1.a;
	q[1] = p2.a;
	q[2] = p3.a;
	q[3] = p4.a;
	k = q;
	for (g = 0; g<10; g++){
		for (h = g; h<10; h++){
			if (*(k + h)>*(k + g)){
				int temp = 0;
				temp = *(k + g);
				*(k + g) = *(k + h);
				*(k + h) = temp;
			}
		}
	}
	cout << "语文最高分:" << q[0] << endl;
	cout << "英语成绩列表" << endl;
	while (head != NULL){
		cout << head->b << endl;
		head = head->next;
	}
	head = &p1;
	w[0] = p1.b;
	w[1] = p2.b;
	w[2] = p3.b;
	w[3] = p4.b;
	k = w;
	for (g = 0; g<10; g++){
		for (h = g; h<10; h++){
			if (*(k + h)>*(k + g)){
				int temp = 0;
				temp = *(k + g);
				*(k + g) = *(k + h);
				*(k + h) = temp;
			}
		}
	}
	cout << "英语最高分:" << w[0] << endl;
	cout << "数学成绩列表" << endl;
	while (head != NULL){
		cout << head->c << endl;
		head = head->next;
	}
	t[0] = p1.c;
	t[1] = p2.c;
	t[2] = p3.c;
	t[3] = p4.c;
	k = t;
	for (g = 0; g<10; g++){
		for (h = g; h<10; h++){
			if (*(k + h)>*(k + g)){
				int temp = 0;
				temp = *(k + g);
				*(k + g) = *(k + h);
				*(k + h) = temp;
			}
		}
	}
	cout << "数学最高分:" << t[0] << endl;
	cout << "是否修改学生信息  1:是 ,2:否" << endl;
	cin >> m;
	p->xg(m);
	while (1){
		cout << "输入想要按哪种格式查询:1.学号 2.姓名" << endl;
		cin >> f;
		switch (f){
		case 1:
			cout << "输入想要查询的学号:" << endl;
			cin >> g;
			p->show(g);
			break;
		case 2:
			cout << "输入想要查询的姓名:" << endl;
			cin >> r;
			if (r == p1.j){
				cout << "学号:" << p1.i << "姓名:" << p1.j << "语文成绩:" << p1.a << "英语成绩:" << p1.b << "数学成绩:" << p1.c << "他的总成绩" << p1.a + p1.b + p1.c << endl;
			}
			else if (r == p2.j){
				cout << "学号:" << p2.i << "姓名:" << p2.j << "语文成绩:" << p2.a << "英语成绩:" << p2.b << "数学成绩:" << p2.c << "他的总成绩" << p2.a + p2.b + p2.c << endl;
			}
			else if (r == p3.j){
				cout << "学号:" << p3.i << "姓名:" << p3.j << "语文成绩:" << p3.a << "英语成绩:" << p3.b << "数学成绩:" << p3.c << "他的总成绩" << p3.a + p3.b + p3.c << endl;
			}
			else if (r == p4.j){
				cout << "学号:" << p4.i << "姓名:" << p4.j << "语文成绩:" << p4.a << "英语成绩:" << p4.b << "数学成绩:" << p4.c << "他的总成绩" << p4.a + p4.b + p4.c << endl;
			}
			break;
		}
	}
	system("pause");
}

你可能感兴趣的:(c++)