?? 管理程序.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<<"班級總數(shù)為:"<<NO<<endl;
}
};
int Class_student::NO=0;
class Grade_manager{
float math,phy,chem;
public:
void set_math(){
cout<<"請輸入數(shù)學(xué)成績:";
cin>>math;
}
void set_phy(){
cout<<"請輸入物理成績:";
cin>>phy;
}
void set_chem(){
cout<<"請輸入化學(xué)成績:";
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<<"請輸入學(xué)生名字:";
cin>>name;
}
void set_sex(){
cout<<"請輸入學(xué)生性別:(0表示男生,1表示女生)";
cin>>sex;
}
void set_age(){
cout<<"請輸入學(xué)生年齡:";
cin>>age;
}
void set_ID(){
cout<<"請輸入學(xué)生學(xué)號:";
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<<"學(xué)號:"<<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<<"輸入學(xué)生的檔案請按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,數(shù)學(xué);2,物理;3,化學(xué)"<<endl;
cin>>b;
switch(b){
case 1:
cout<<"數(shù)學(xué)成績由高到底排序為:"<<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<<"化學(xué)成績由高到底排序為:"<<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;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -