資源簡介
用c/c++寫的學生教師管理系統,有菜單界面等,是自己的課程設計
代碼片段和文件信息
//?06271.cpp?:?Defines?the?entry?point?for?the?console?application.
//
//#include?“stdafx.h“
#include
#include
#pragma?once
#include
#include
using?namespace?std;
class?people??
{
public:
people(int?nuchar?na[30]char?s[15]char?o[50]char?d[30]int?a);
virtual?~people();
//protected:
int?num;//學號
char?name[30];//名字
char?sex[15];//性別
char?major_or_department[50];//專業和工作系別
char?date[30];//出生日期
int?age;//年齡
};
people::people(int?nuchar?na[30]char?s[15]char?o[50]char?d[30]int?a)
{
num=nu;
strcpy(namena);
strcpy(sexs);
strcpy(major_or_departmento);
strcpy(dated);
age=a;
}
people::~people()
{
}
//***********************************************************************************
class?student?:?public?people??
{
public:
student(int?nu=0char?na[30]=““char?s[15]=““char?o[50]=““char?d[15]=““int?a=0int?c=0int?e=0int?m=0);
virtual?~student();
friend?istream?&operator>>(const?istream?&isstudent?&stu);//重載“>>“運算符函數聲明
friend?ostream?&operator<<(const?ostream?&osstudent?&stu);//重載“<<“運算符函數聲明
void?AddData();//添加學生數據
void?DisplayData();//輸出學生數據
void?save(ofstream?&outf);//輸入學生數據到文件
void?load(ifstream?&inf);//從文件輸出學生數據
friend?void?SAddData();//對學生類對象的添加功能函數調用AddData函數
friend?void?SDeleteData();//對學生類對象的刪除功能函數
friend?void?SUpdateData();//對學生類對象的修改功能函數
friend?void?SSearchData_num();//按學號查詢學生類對象
friend?void?SSearchData_nam();//按姓名查詢學生類對象
friend?void?SSearchData_sex();//按性別查詢學生類對象
friend?void?SFindMaxData();//對學生類對象的最高英語成績查詢功能函數
friend?void?SDisplayData();//對學生類對象按學號升序排序打印功能函數
friend?void?Ssave();//對學生類對象的保存功能函數
friend?void?Sload();//對學生類對象的讀取功能函數
//protected:
int?score_chinese;
int?score_english;
int?score_mathematices;
};
int?S;
student?stu1[10];
student::student(int?nuchar?na[30]char?s[15]char?o[50]char?d[15]int?aint?cint?eint?m):people(nunasoda)
{
score_chinese=c;
score_english=e;
score_mathematices=m;
}
student::~student()
{
}
istream?&operator>>(??istream?&is?student?&stu)//重載“>>“運算符函數聲明
{
is>>stu.name;??
is.getline(stu.name30‘\n‘);?//使其能夠讀入字符串中的空格?
is>>stu.sex;?
is>>stu.major_or_department;??
is>>stu.date;??
is>>stu.age;
is>>stu.score_chinese;??
is>>stu.score_english;
is>>stu.score_mathematices;
return?is;?//退出函數
}
ostream?&operator<<(ostream?&osstudent?&stu)//重載“<<“運算符函數聲明
{???
os< os< os< os< os< os< os< os< os< return?os;?//退出函數
}?
void?student::AddData()
{
int?k;?
system(“cls“);
cr:cout<<“請輸入學號:“;
cin>>num;
for(int?i=0;i<10;i++)
{
if(i!=S&&stu1[S].num==stu1[i].num)
{
cout<<“輸入學號重復,請重新輸入!“< goto?cr;
}
}
for(k=1;k<11;k++)
{
if(num==k)
k=11;
}
- 上一篇:小區水電費管理系統
- 下一篇:51單片機實現8個流水燈
評論
共有 條評論