C語(yǔ)言程序設(shè)計(jì)綜合作業(yè)報(bào)告——作業(yè)管理系統(tǒng)
1.1系統(tǒng)概要
(1)?????? 進(jìn)入系統(tǒng)之前,用戶輸入密碼1234,進(jìn)入,共有3次機(jī)會(huì)。
(2)?????? 用戶根據(jù)需要輸入(0~5)或(0~6)實(shí)現(xiàn)不同的功能,若輸入其他字符,則顯示按鍵錯(cuò)誤,并返回界面讓用戶重新選擇。
(3)?????? 按0退出。
?
1.2基本功能要求
(1) 程序運(yùn)行時(shí)首先給出密碼輸入菜單:
?
(2)用戶進(jìn)入系統(tǒng)后,顯示6個(gè)或7個(gè)菜單的主要功能:
?
(3)流程圖
?
?
1.3主要知識(shí)點(diǎn)
(1) 使用鏈表。
(2) 用多文件管理工程。
(3) 使用switch~case語(yǔ)句。
(4) 用while語(yǔ)句實(shí)現(xiàn)循環(huán)。
(5) 用類實(shí)現(xiàn)封裝和管理數(shù)據(jù)。
(6) 用清屏函數(shù)
(7) 使用文件
?
1.4系統(tǒng)設(shè)計(jì)思路與算法
(1)?????? 打開(kāi)open
?
(2)?????? 添加add
?
(3)?????? 保存save
?
(4)?????? 查找find
?
(5)?????? 顯示list
?
(6)?????? 退出exit
清屏前
?
清屏后
?
?
1.5源程序代碼
數(shù)組程序
/************************************************************************/
/* Student類???????????????????????????????????????????????????????????? */
/************************************************************************/
class student
{
public:
??????????? student()
??????????? {
??????????????????????? Name="noname";
??????????????????????? Num=0;
??????????????????????? Ponenum=0;
??????????????????????? Homework="noname";
??????????? }
??????????? void SetName();
??????????? void SetNum();
??????????? void SetPonenum();
??????????? void SetHomework();
??????????? string GetName()const{return Name;}
??????????? int GetNum()const{return Num;}
??????????? long GetPonenum()const{return Ponenum;}
??????????? string GetHomework()const{return Homework;}
??????????? void Setall();
??????????? void Display();
protected:
private:
??????????? int Num;
??????????? string Name;
??????????? long Ponenum;
??????????? string Homework;
};
/************************************************************************/
/* Setall()函數(shù)的實(shí)現(xiàn)??????????????????????????????????????????? ???????????*/
/************************************************************************/
void student::Setall()
{
??????????? SetNum();
??????????? SetName();
??????????? SetPonenum();
??????????? SetHomework();
}
/************************************************************************/
/* Set~()函數(shù)的實(shí)現(xiàn)?????????????????????????????????????????????????????? */
/************************************************************************/
??????????? void SetName()
??????????? {
??????????????????????? cout<<"請(qǐng)輸入學(xué)生的名字:";
??????????????????????? cin>>Name;
?
??????????? }
??????????? void SetNum()
??????????? {
??????????????????????? cout<<"請(qǐng)輸入學(xué)生的序號(hào):";
??????????????????????? cin>>Num;
??????????? }
??????????? void SetPonenum()
??????????? {
??????????????????????? cout<<"請(qǐng)輸入學(xué)生的電話號(hào)碼:";
??????????????????????? cin>>Ponenum;?
??????????? }
??????????? void SetHomework()
??????????? {
??????????????????????? cout<<"請(qǐng)輸入學(xué)生的作業(yè)名:";
??????????????????????? cin>>Homework;
??????????? }
/************************************************************************/
/* Display()函數(shù)的實(shí)現(xiàn)?????????????????????????????????????????? ????????????*/
/************************************************************************/
void student::Display()
{
??????????? cout<<"學(xué)生的序號(hào)為:"<<GetNum()<<endl;
??????????? cout<<"學(xué)生的名字為:"<<GetName()<<endl;
??????????? cout<<"學(xué)生的電話號(hào)碼為:"<<GetPonenum()<<endl;
??????????? cout<<"學(xué)生的作業(yè)為:"<<GetHomework()<<endl;
}
/************************************************************************/
/* 密碼界面的實(shí)現(xiàn)?????????????????????????????????????????????????????? */
/************************************************************************/
??????????? for (int n=1;n<=3;n++)
??????????? {
??????????? ??? cout<<"請(qǐng)輸入密碼:";
??????????????????????? int code;
??????????????????????? cin>>code;
??????????????????????? if (code==1234)
??????????????????????? {
??????????????????????????????????? cout<<"????? 您成功進(jìn)入了系統(tǒng)!??? "<<endl;
??????????????????????????????????? cout<<"?????????????? ================================"<<endl;
??????????????????????? ??? cout<<"???????????????????? 歡迎使用作業(yè)管理系統(tǒng)!??? "<<endl;
??????????????????????? ??? cout<<"?????????????? ================================"<<endl;
??????????????????????????????????? i=1;
??????????????????????????????????? break;
??????????????????????? }
??????????????????????? else
??????????????????????????????????? cout<<"????? 您輸入的不正確,請(qǐng)重新輸入!"<<endl;
??????????? ???? ?????? i=0;
??????????? }
??????????? if (n==4)
??????????? cout<<"您已輸入三次,請(qǐng)下次再試!";
/************************************************************************/
/* 文件管理? 保存????????????????????????????????????????????????? */
/************************************************************************/
??????????????????????????????????? fout.open("c.txt",ios::app);
??????????????????????????????????? fout<<"學(xué)生的序號(hào)為:"<
??????????????????????????????????? fout<<"學(xué)生的名字為:"<
??????????? ? ? ? ? ? ? ? ? ? ? ? ??fout<<"學(xué)生的電話號(hào)碼為:"<
??????????? ? ? ? ? ? ? ? ? ? ? ? ??fout<<"學(xué)生的作業(yè)為:"<
??????????????????????????????????? fout<<endl;
??????????????????????????????????? fout.close();
/************************************************************************/
/* 文件管理? 打開(kāi)???????????????????????????????????????????????? */
/************************************************************************/????? ????????????????????? ???????
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? fin.open("c.txt");
??????????????????????????????????? if(!fin)
??????????????????????????????????? {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?cout<<"沒(méi)有找到您要的文件!"<<endl;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?break;
??????????????????????????????????? }
??????????????????????????????????? while (fin.get(ch))
??????????????????????????????????? {
??????????????????????????????????????????????? cout<<ch;
??????????????????????????????????? }
??????????????????????????????????? cout<<endl;
??????????????????????????????????? fin.close();