版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
第C++實(shí)現(xiàn)宿舍管理查詢系統(tǒng)stu.r[i]=stu.r[i-1];
for(j=i-2;stu.r[0].idstu.r[j].id;j--)
stu.r[j+1]=stu.r[j];
stu.r[j+1]=stu.r[0];
}
ofstreamoutfile("student.txt",ios::out);
if(!outfile){
//如果文件打開失敗
cout"文件打開失敗"endl;
exit(1);
}
//outfile"學(xué)號"setw(8)"姓名"setw(8)"宿舍號"endl;
outfilestu.lengthendl;
for(i=1;i=stu.length;i++){
outfilestu.r[i].idsetw(8)stu.r[i].namesetw(8)stu.r[i].dormidendl;
}
cout"學(xué)生信息數(shù):"stu.lengthendl;
outfile.close();
coutstu.length;
//創(chuàng)建學(xué)生信息(只能創(chuàng)建一次,不然會被刷新)
voidInitList(SqListstu)
inti;
cout"學(xué)號"setw(8)"姓名"setw(8)"宿舍號"endl;
for(i=1;i=stu.length;i++){
cinstu.r[i].idstu.r[i].namestu.r[i].dormid;
}
InsertSort(stu);
//增加學(xué)生信息
voidAddstudent(SqListstu)
intn;
inti=stu.length+1;
cout"輸入增加學(xué)生人數(shù)"endl;
cinn;
cout"學(xué)號"setw(8)"姓名"setw(8)"宿舍號"endl;
stu.length=stu.length+n;
for(i;i=stu.length;i++)
cinstu.r[i].idstu.r[i].namestu.r[i].dormid;
InsertSort(stu);
//查詢學(xué)生信息
voidFindstudent(SqListstu)
stringa,b,c;
stringname,id,dormid;
cout"1.學(xué)號查詢
2.姓名查詢
3.宿舍號查詢"endl;
cout"請輸入你的查詢選擇(1~3)"endl;
inti;
intn;
cinn;
if(n1n3)
{
cout"您輸入有誤,請重新輸入:"endl;
Findstudent(stu);
}
if(1==n)
{
cout"請輸入學(xué)生學(xué)號:"endl;
cinid;
ifstreaminfile("student.txt",ios::in);//定義輸入文件流對象,以輸入方式打開磁盤文件"student.txt"
infilestu.length;
for(i=1;i=stu.length;i++){
infilestu.r[i].idstu.r[i].namestu.r[i].dormid;
}
infile.close();
for(i=1;i=stu.length;i++)
{
infilestu.r[i].idstu.r[i].namestu.r[i].dormid;
if(stu.r[i].id==id)
coutstu.r[i].idsetw(8)stu.r[i].namesetw(8)stu.r[i].dormidendl;
}
infile.close();//關(guān)閉磁盤文件
}
if(2==n)
{
cout"請輸入學(xué)生姓名:"endl;
cinname;
ifstreaminfile("student.txt",ios::in);//定義輸入文件流對象,以輸入方式打開磁盤文件"student.txt"
infilestu.length;
for(i=1;i=stu.length;i++){
infilestu.r[i].idstu.r[i].namestu.r[i].dormid;
}
infile.close();
for(i=1;i=stu.length;i++)
{
infilestu.r[i].idstu.r[i].namestu.r[i].dormid;
if(stu.r[i].name==name)
coutstu.r[i].idsetw(8)stu.r[i].namesetw(8)stu.r[i].dormidendl;
}
infile.close();//關(guān)閉磁盤文件
}
if(3==n)
{
cout"請輸入學(xué)生宿舍號:"endl;
cindormid;
ifstreaminfile("student.txt",ios::in);//定義輸入文件流對象,以輸入方式打開磁盤文件"student.txt"
infilestu.length;
for(i=1;i=stu.length;i++){
infilestu.r[i].idstu.r[i].namestu.r[i].dormid;
}
infile.close();
for(i=1;i=stu.length;i++)
{
infilestu.r[i].idstu.r[i].namestu.r[i].dormid;
if(stu.r[i].dormid==dormid)
coutstu.r[i].idsetw(8)stu.r[i].namesetw(8)stu.r[i].dormidendl;
}
}
//修改學(xué)生信息
voidRenewstudent(SqListstu)
intn;
stringid,name,dormid;
cout"1.姓名
2.宿舍號"endl;
cout"請輸入您的選擇(1~2):"endl;
cinn;
cout"請輸入需要修改學(xué)生的學(xué)號"endl;
cinid;
if(n!=1n!=2)
{
cout"輸入有誤,請重新輸入:"endl;
Renewstudent(stu);
}
if(1==n)
{
cout"請輸入修改姓名"endl;
cinname;
inti=0;
ifstreaminfile("student.txt",ios::in);
infilestu.length;
for(i=1;i=stu.length;i++){
infilestu.r[i].idstu.r[i].namestu.r[i].dormid;
}
infile.close();
for(i=1;i=stu.length;i++)//先找到再修改
{
if(stu.r[i].id==id)
{
stu.r[i].name=name;
InsertSort(stu);
return;
}
}
}
if(2==n)
{
inti;
cout"請輸入修改宿舍號"endl;
cindormid;
ifstreaminfile("student.txt",ios::in);
infilestu.length;
for(i=1;i=stu.length;i++){
infilestu.r[i].idstu.r[i].namestu.r[i].dormid;
}
infile.close();
for(i=1;i=stu.length;i++)//先找到再修改
{
if(stu.r[i].id==id)
{
stu.r[i].dormid=dormid;
InsertSort(stu);
return;
}
}
}
//顯示宿舍信息
voidShowstudent(SqListstu)
stringa,b,c;
inti;
cout"學(xué)生的信息如下:"endl;
cout"**********************************"endl;
ifstreaminfile("student.txt",ios::in);
if(!infile){
//如果文件打開失敗
cout"文件打開失敗"endl;
exit(1);
}
/*infileabc;//從磁盤文件讀入
coutasetw(8)bsetw(8)cendl;//在顯示器上顯示*/
infilestu.length;
for(i=1;i=stu.length;i++){
infilestu.r[i].idstu.r[i].namestu.r[i].dormid;
coutstu.r[i].idsetw(8)stu.r[i].namesetw(8)stu.r[i].dormidendl;
}
infile.close();
//刪除宿舍信息
voidDeletstudent(SqListstu)
int
i,j;
stringa,b,c,id;
cout"請輸入刪除學(xué)生學(xué)號"endl;
cinid;
ifstreaminfile("student.txt",ios::in);//定義輸入文件流對象,以輸入方式打開磁盤文件"student.txt"
infilestu.length;
for(i=1;i=stu.length;i++){
infilestu.r[i].idstu.r[i].namestu.r[i].dormid;
}
infile.close();
for(i=1;i=stu.length;i++)//先找到再刪除
{
if(stu.r[i].id==id)
{
for(j=i;jstu.length;j++)
stu.r[j]=stu.r[j+1];
stu.length--;
InsertSort(stu);
return;
}
}
//主函數(shù)
intmain()
SqListstu;
intn;
for(;;)
{
cout"**************************宿舍管理查詢軟件**************************"endl;
cout"1.創(chuàng)建學(xué)生信息"endl;
//InitList
cout"2.增加學(xué)生信息"endl;
//Addstudent
cout"3.查詢學(xué)生信息"endl;
//Findstudent
cout"4.顯示學(xué)生信息"endl;
//Showstudent
cout"5.修改學(xué)生信息"endl;
//Renewstudent
cout"6.刪除學(xué)生信息"endl;
//Deletstudent
cout"0.退出系統(tǒng)"endl;
cout"*******************************************************************"endl;
cout"請輸入你需要的操作(0~6):"endl;
cinn;
switch(n)
{
case1:
cout"輸入學(xué)生人數(shù)"endl;
cinstu.length;
InitList(stu);
cout"###########################################"endl;
break;
case2:
Addstudent(stu);
cout"###########
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年中職通信技術(shù)(移動通信基礎(chǔ))試題及答案
- 2025年高職中草藥栽培與加工技術(shù)(中藥炮制基礎(chǔ))試題及答案
- 2025年大學(xué)(麻醉學(xué))麻醉心理學(xué)試題及答案
- 2025年中職航空服務(wù)(客艙服務(wù)實(shí)務(wù))試題及答案
- 2025年中職(煙草栽培)煙草大田移栽階段測試試題及答案
- 2025年大學(xué)醫(yī)學(xué)影像技術(shù)(CT影像診斷)試題及答案
- 2025年中職(農(nóng)產(chǎn)品營銷與儲運(yùn))農(nóng)產(chǎn)品儲存試題及答案
- 2025年中職物流類(物流故障處理)試題及答案
- 2025年大學(xué)化學(xué)工程與工藝(化工系統(tǒng)工程)試題及答案
- 2025年中職人工智能類(人工智能基礎(chǔ)常識)試題及答案
- 2025年大學(xué)大一(中國文化史)歷史發(fā)展階段測試題及答案
- 豆豆錢解協(xié)議書
- 2025年甘肅省白銀市靖遠(yuǎn)縣石門鄉(xiāng)人民政府選聘專業(yè)化管理村文書(公共基礎(chǔ)知識)綜合能力測試題附答案解析
- 肝內(nèi)膽管癌護(hù)理查房
- 新生兒護(hù)理技能與并發(fā)癥預(yù)防
- 交易合同都保密協(xié)議
- 北師大版(2024)八年級上冊數(shù)學(xué)期末考試模擬強(qiáng)化訓(xùn)練試卷3(含答案)
- 2026年遼寧現(xiàn)代服務(wù)職業(yè)技術(shù)學(xué)院單招綜合素質(zhì)考試題庫及完整答案詳解1套
- 公立醫(yī)院績效考核方案細(xì)則
- 2025福建福州工業(yè)園區(qū)開發(fā)集團(tuán)有限公司招聘4人考試備考題庫及答案解析
- 小學(xué)英語測試題設(shè)計(jì)思路
評論
0/150
提交評論