⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 管理程序.cpp

📁 一个学生成绩管理程序
💻 CPP
字号:
// 管理程序.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream.h>
#define MALE 0,FEMALE 1;
#define MAX 9999;

class Class_student{
	int ID;
	static int NO;
public:
	Class_student(){NO++;};
	void set_ID(){
		cout<<"请输入班级号:";
		cin>>ID;
	}
	void get_ID(){
		cout<<"班级号:"<<ID<<endl;
	}
	void get_NO(){
		cout<<"班级总数为:"<<NO<<endl;
	}
};
int Class_student::NO=0;
class Grade_manager{
	float math,phy,chem;
public:
	void set_math(){
		cout<<"请输入数学成绩:";
		cin>>math;
	}
	void set_phy(){
		cout<<"请输入物理成绩:";
		cin>>phy;
	}
	void set_chem(){
		cout<<"请输入化学成绩:";
		cin>>chem;
	}
	float get_math(){
		return math;
	}
	float get_phy(){
		return phy;
	}
	float get_chem(){
		return chem;
	}
};
class Student:public Grade_manager,public Class_student{
	char* name;
	int sex;
	int age;
	double ID;
public :
	Student(){};
	void set_name(){
		name=new char[128];
		cout<<"请输入学生名字:";
		cin>>name;
	}
	void set_sex(){
		cout<<"请输入学生性别:(0表示男生,1表示女生)";
		cin>>sex;
	}
	void set_age(){
		cout<<"请输入学生年龄:";
		cin>>age;
	}
	void set_ID(){
		cout<<"请输入学生学号:";
		cin>>ID;
	}
	void get_name(){
		cout<<"名字:"<<name<<endl;
	}
	void get_sex(){
		switch(sex){
		case 0:
			cout<<"性别:"<<"MALE"<<endl;
			break;
		case 1:
			cout<<"性别:"<<"FEMALE"<<endl;
			break;
		}
	}
	void get_age(){
		cout<<"年龄:"<<age<<endl;
		
	}
	void get_ID(){
		cout<<"学号:"<<ID<<endl;
		
	}
};
class Teacher:public Class_student{
	char *name;
	int sex;
	int age;
public:
	Teacher(){};
	void set_name(){
		name=new char[128];
		cout<<"请输入老师名字:";
		cin>>name;
	}
	void set_sex(){
		cout<<"请输入老师性别:(0表示男生,1表示女生)";
		cin>>sex;
	}
	void set_age(){
		cout<<"请输入老师年龄:";
		cin>>age;
	}
	void get_name(){
		cout<<"名字:"<<name<<endl;
	}
	void get_sex(){
		switch(sex){
		case 0:
			cout<<"性别:"<<"MALE"<<endl;
			break;
		case 1:
			cout<<"性别:"<<"FEMALE"<<endl;
			break;
		}
	}
	void get_age(){
		cout<<"年龄:"<<age<<endl;
		
	}
};

void main(){
	Student student_temp;
    Student temp[100];
	Teacher teacher_temp;
	Teacher teachertemp[100];
	for(int m=0;m<=1000;m++){
		int n=0;
		cout<<"输入学生的档案请按1,输入老师的档案请按2,返回请按其他键:";
		cin>>n;
		
		if(n==1){
			student_temp.set_sex();
			student_temp.set_ID();
			student_temp.set_name();
			student_temp.set_age();
			student_temp.set_math();
			student_temp.set_phy();
			student_temp.set_chem();
			student_temp.get_sex();
			student_temp.get_ID();
			student_temp.get_name();
			student_temp.get_age();
			
		}
		else if(n==2){
			teacher_temp.set_sex();
			teacher_temp.set_ID();
			teacher_temp.set_age();
			teacher_temp.set_name();
			teacher_temp.get_sex();
			teacher_temp.get_ID();
			teacher_temp.get_age();
			teacher_temp.get_name();
		}
		else

			break;
		
		temp[m]=student_temp;
		
	}
	for(int a=0;a<=100;a++){
		int b;
		int c=0;
        int d=0;
		int e=0;
		int q=0;
		Student p=temp[0];
		cout<<"请选择要排序的成绩:1,数学;2,物理;3,化学"<<endl;
		cin>>b;
		switch(b){
		case 1:
              cout<<"数学成绩由高到底排序为:"<<endl;
				 for(;c<=m;c++){
					 for(q=c;q<m;q++){
						 if(p.get_math()<temp[q+1].get_math()){
							//p.get_math()=temp[q+1].get_math();
							 //temp[q+1].get_math()=temp[q].get_math();
                             //temp[q].get_math()=p.get_math();
						 }
					 }
					 cout<<temp[c].get_math()<<endl;
				 }
				 break;
		case 2:
			cout<<"物理成绩由高到底排序为:"<<endl;
				 for(;c<=m;c++){
					 for(q=c;q<m;q++){
						 if(p.get_phy()<temp[q+1].get_phy()){
							//p.get_phy()=temp[q+1].get_phy();
							 //temp[q+1].get_phy()=temp[q].get_phy();
                             //temp[q].get_phy()=p.get_phy();
						 }
					 }
					 cout<<temp[c].get_phy()<<endl;
				 }
				 break;
		case 3:
			cout<<"化学成绩由高到底排序为:"<<endl;
				 for(;c<=m;c++){
					 for(q=c;q<m;q++){
						 if(p.get_chem()<temp[q+1].get_chem()){
							//p.get_chem()=temp[q+1].get_chem();
							 //temp[q+1].get_chem()=temp[q].get_chem();
                             //temp[q].get_chem()=p.get_chem();
						 }
					 }
					 cout<<temp[c].get_chem()<<endl;
				 }
				 break;
		}
	}

    
}








	




 




		



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -