資源簡介
南京郵電大學(xué)課程設(shè)計,內(nèi)含詳細(xì)的源碼和試驗報告!

代碼片段和文件信息
#include
#include
#include
#include?
class?Student{
private:
??char?StuNumber[10];
??char?Sex;
??int?Height;
??int?Weight;
public:
??Student()
??{
???cout<<“Student?constructing...“< ??}
??~Student()
??{
???cout<<“Student?Destructing...“< ??}
??friend?void?Input(fstreamStudent?*);
??friend?void?Search(fstreamStudent?*);
??friend?void?Search1(fstreamStudent?*);
??friend?void?MaxandMinHeightSearch(fstreamStudent?*);
??friend?void?MaxandMinWeightSearch(fstreamStudent?*);
??friend?void?PercentHeightandWeight(fstreamStudent?*);
??friend?void?Health(fstreamStudent?*);
??friend?ostream?&operator<<(ostream?&outStudent?&stu);
??friend?istream?&operator>>(istream?&inStudent?&stu);
};
//重載運算符<<
ostream?&operator<<(ostream?&outStudent?&stu)
{
out< ??return?out;
}
//重載運算符>>以方便下面整體輸出
istream?&operator>>(istream?&inStudent?&stu)
{
??in>>stu.StuNumber>>stu.Sex>>stu.Height>>stu.Weight;
??return?in;
}
//輸入學(xué)生信息的函數(shù)
void?Input(fstream?opStudent?*p)
{
??int?numcounter=1;
??cout<<“請輸入學(xué)生總數(shù):“;
??cin>>num;
??cout<<“請按以下格式錄入學(xué)生信息:“< ??cout<<“??學(xué)號???性別???身高???體重“< ??cout<<“---------------------------------------“< ??while(counter<=num)
??{
???cin>>*p;
???op.write((char?*)?psizeof(Student));
???counter++;
??}
??cout<<“---------------------------------------“< }
//查詢所有數(shù)據(jù)的函數(shù)
void?Search(fstream?opStudent?*p)
{
??int?flag=0;
??cout<<“---------------------------------------“< ??while(op.read((char?*)?psizeof(Student)))
??{
???cout<<*p< ??flag=1;
??}
??if(!flag)
??{
???cout<<“數(shù)據(jù)庫中沒有數(shù)據(jù)“< ??}
??cout<<“---------------------------------------“< }
//按學(xué)號查詢數(shù)據(jù)的函數(shù)
void?Search1(fstream?opStudent?*p)
{
??char?str[10];
??int?flag=0;
??cout<<“---------------------------------------“< ??cout<<“請輸入需要查詢的學(xué)生學(xué)號:“;
??cin>>str;
??while(op.read((char?*)?psizeof(Student)))
??{
???if(strcmp(strp->StuNumber)==0)
???{
????cout<<*p< ????flag=1;
???}
??}
??if(!flag)
??{
???cout<<“對不起,沒有符合您的要求的數(shù)據(jù)“< ??}
??cout<<“---------------------------------------“< }
//按性別查詢具有最大身高、最小身高的學(xué)生的情況數(shù)據(jù)的函數(shù)
void?MaxandMinHeightSearch(fstream?opStudent?*p)
{
??char?a;
??int?str[12];
??int?i=0;
??int?flag=0;
??cout<<“---------------------------------------“< ??cout<<“請輸入需要查詢的最大身高、最小身高的學(xué)生的性別:“< ??cin>>a;??
??cout<<“---------------------------------------“< ??while(op.read((char?*)?psizeof(Student)))
??{
???if(a==p->Sex)
???{
????str[i]=p->Height;
????i++;
?flag=1;
???}
??}
??op.close();
???int?max=str[0]min=str[0];
???for(int?j=1;j???{
????if(str[j]>max)
????max=str[j];
???else?if(str[j] ????min=str[j];
??}
???op.open(“D:\\Shealth.txt“ios::in|ios::app);
while(op.read((char?*)?psizeof(Student)))
??{
??if(a==p->Sex)
??{
???????if(max==p->Height)
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????360??2007-06-07?16:17??程序設(shè)計B06021933\Shealth.txt
?????文件????????200??2007-06-07?16:35??程序設(shè)計B06021933\wrong.txt
?????文件???????9459??2007-06-07?16:32??程序設(shè)計B06021933\學(xué)生健康狀況調(diào)查系統(tǒng)-B06021933.cpp
?????文件?????229448??2007-06-07?16:29??程序設(shè)計B06021933\學(xué)生健康狀況調(diào)查系統(tǒng)-B06021933.exe
?????文件?????249856??2008-02-29?17:35??程序設(shè)計B06021933\程序設(shè)計報告—B06021933.doc
?????目錄??????????0??2008-03-08?15:12??程序設(shè)計B06021933
-----------?---------??----------?-----??----
???????????????489323????????????????????6
- 上一篇:glut.3.7.6+.DevPak
- 下一篇:C語言計算特征值和特征向量
評論
共有 條評論