|
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
const char null='\0';
void _() //分隔符
{
int i;
for(i=0;i<=79;i++)
if(i<=79)
cout<<"-";
}
void menu()
{
cout<<"\t\t\t\t成绩管理系统"<<endl;
_();
cout<<"1.信息录入\t2.信息修改\t3.信息删除\t4.信息排序\t5.退出"<<endl;
_();
cout<<"选择:";
}
class student_info
{
protected:
char *no; //学号
char *name; //姓名
public:
void setinfo(char *no1,char *name1); //设置函数
void printfinfo(); //信息输出
~student_info(){delete []no;delete []name;} //析构函数
};
void student_info::setinfo(char *no1,char *name1)
{
cout<<"输入学号:";
cin>>no1;
no1=new char[strlen(no1)+1];
strcpy(no,no1);
cout<<"输入姓名:";
cin>>name1;
name1=new char[strlen(name1)+1];
strcpy(name1,name);
}
void student_info::printfinfo()
{
cout<<"学号:"<<no<<endl<<"姓名:"<<name<<endl;
}
class student_grade:public student_info
{
protected:
float gokugo;
float eigo;
float suugaku;
float konpyu_ta_;
static float sum;
static int count;
float ave;
public:
void setgrade();
void printfgrade();
};
void student_grade::setgrade()
{
printfinfo();
cout<<"输入国语成绩:";
cin>>gokugo;
cout<<"输入英语成绩:";
cin>>eigo;
cout<<"输入数学成绩:";
cin>>suugaku;
cout<<"输入计算机成绩:";
cin>>konpyu_ta_;
count++;
}
void student_grade::printfgrade()
{
cout<<"\n国语成绩:"<<gokugo<<"\n英语成绩:"<<eigo<<"数学成绩:"<<suugaku<<"计算机成绩:"<<konpyu_ta_<<endl;
}
void tj() //添加函数
{
student_grade g1,*g;
g=&g1;
g->setgrade();
}
float student_grade::sum=0;
int student_grade::count=0;
void main()
{
int select;
menu();
cin>>select;
switch(select)
{
case 1:tj();break;
case 5:system("cls");cout<<"\t\t按任意键退出\n";exit(1);break;
default:cout<<"错误!"<<endl;
}
} |
|