




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、學號2016-2017學年 第二學期高級語言程序設計課程設計報告題目:學生選課系統(tǒng)專業(yè):網(wǎng)絡工程(對口)班級:16(3)班姓名:代應豪指導教師:代美麗成績:計算機學院2017 年 4月 25 日目 錄一 需求分析1三 詳細設計21.數(shù)據(jù)定義22.算法流程圖2四 函數(shù)5五 測試6六 設計總結9七 參考文獻10八 源程序10一 需求分析數(shù)據(jù)結構可用結構體,包括課程和選修兩個結構體,其中課程結構體成員結構體成員包括課程編號,課程名稱,課程性質,總學時,授課學時,實驗或上機學時,學分,開課學期。選修結構體成員包括學號,課程編號,該結構體的建立主要是為了查詢某門課程學生選修情況。 二 總體設計系統(tǒng)由哪幾
2、個功能模塊構成,給出功能模塊圖。C中模塊化的工具是函數(shù)根據(jù)上面的需求分析,可以將這個系統(tǒng)的設計分為如下七大模塊:選課模塊、按學分查找模塊、按編號查找模塊、查看課程模塊、查看選課情況模塊、課程輸入模塊、完成選擇模塊。菜單選擇模塊系統(tǒng)信息查看存儲學生選課學生信息管理錄入學生信息退出系統(tǒng)課程管理錄入課程信息完成選擇模塊三 詳細設計1.數(shù)據(jù)定義顯示一系列功能選項輸入n,判斷是否是1-7根據(jù)n的值調用各功能模塊函數(shù)2.算法流程圖(1)錄入課程信息表錄入課程信息從文件輸入輸入課程編號保存信息到student.txt顯示錄入成功,轉入完成選擇菜單新增課程輸入課程信息保存顯示失敗(2)課程管理Y錄入課程信息輸
3、入數(shù)據(jù)保存(3)錄入課程信息(4)學生信息管理新增學生信息或刪除學生信息輸入姓名,考號。保存(5)學生選課學生選課查詢可選課程查詢已選課程返回主菜單輸入學號輸入學號(6)系統(tǒng)信息及查看系統(tǒng)主菜單系統(tǒng)信息及查看系統(tǒng)查看課程信息查看學生信息存儲信息返回主菜單存儲課程信息存儲學生信息返回主菜單輸入路徑,保存。(7)退出系統(tǒng)完成選擇菜單模塊退出系統(tǒng)、四 函數(shù)1.structcouse*head1;結構2.voidkeyboardc()/錄入課程子函數(shù)(從鍵盤錄入)3.voidfilec()/錄入鍵盤子函數(shù)(從文件錄入)4.voidinputc()/錄入課程主函數(shù)5.voidinsertc(struct
4、couse*incouse)/課程管理子函數(shù)(增加課程)6.voiddelc(intnum1)/課程管理子函數(shù)(刪除課程)7.voidelect(structstudent*s)/選課8.voidcheak()/學生選課子函數(shù)(查詢可選課程)9.voidback(structstudent*p)/退課10.voidhcheak()/學生選課子函數(shù)(查詢已選課程)11.voidelective()/學生選課主函數(shù)12.voidlistc()/輸出課程信息13.voidlists()/輸出學生信息14.voidintoc()/存儲課程信息15.voidintos()/存儲學生信息16.voidin
5、to()/存儲信息17.voidstore()/信息主函數(shù)18.intmain()/主函數(shù) 五 測試1.主菜單2.錄入課程信息3.從鍵盤輸入4.從文件輸入5.學生選課菜單6.學生信息管理7.管理員輸入課程信息界面六 設計總結問題一:無法讀取文txt文件。困難就是txt無法讀取,輸入路徑后沒有文件顯示。解決辦法是,向老師求助。最后,在老師細心的指導下,才知道是自己的計算機操作水平緣故,沒有很好的了解計算機路徑結構,最后做出了一定的修改,才得以實現(xiàn)。問題二:程序錯誤。這是一個比較典型的錯誤,通過查閱書本相關資料。才發(fā)覺是函數(shù)相關問題,沒有能夠很好的理解函數(shù)思想,導致程序運行錯誤。七 參考文獻1姜靈
6、芝,余健.C語言課程設計案例精編.北京:清華大學出版社,20082王新,孫雷.C語言課程設計.北京:清華大學出版社,20093游洪躍、彭駿、譚斌.C語言程序設計實驗與課程設計教程.北京:清華大學出版社,20114王連相.C/C+程序設計上機指導與測試.北京:中國鐵道出版社,20065C語言函數(shù)手冊,機械工業(yè)出版社,1999八 源程序#include #includeint N1,N2,kk1,kk2,kk3;struct couse * head1;struct student * head2;struct couse int num1;/課程編號char name120;/課程名稱char
7、xinzhi30;/課程性質iint ztime;/課程總學時int stime;/授課學時int shiyan;/實驗學時int score;/學分long int date;/開學學期 int nelepeo;/課程已選人數(shù) int Melepeo;/課程人數(shù)上限 struct couse * next;struct student/學生信息結構體 int num2; char name220; int nelenum50;/已選課程編號 int nelen;/已選課程數(shù)量 struct student * next;void Ms() for(kk1=0;kk11100;kk1+) fo
8、r(kk2=0;kk21200;kk2+) for(kk3=0;kk3num1,p1-name1,&p1-xinzhi,&p1-ztime,&p1-stime,&p1-shiyan,&p1-score,&p1-date,&p1-Melepeo); p1-nelepeo=0; head1=NULL; while(p1-num1!=0) N1=N1+1; if(N1=1)head1=p1; else p2-next=p1; p2=p1; p1=(struct couse * )malloc(sizeof(struct couse); scanf(%d%s%s%d%d%d%d%d,&p1-num1,
9、p1-name1,&p1-xinzhi,&p1-ztime,&p1-stime,&p1-shiyan,&p1-score,&p1-date,&p1-Melepeo); p1-nelepeo=0; p2-next=NULL;void filec()/錄入鍵盤子函數(shù)(從文件錄入) FILE * fp; char filepath20; struct couse *p1,*p2; N1=0; printf(輸入要讀入的文件路徑:); getchar(); gets(filepath); if(fp=fopen(filepath,r)=NULL) printf(找不到%s文件!n,filepath);
10、 exit(0); p1=p2=(struct couse*)malloc(sizeof(struct couse); fscanf(fp,%d%s%s%d%d%d%d%d,&p1-num1,&p1-name1,&p1-xinzhi,&p1-ztime,&p1-stime,&p1-shiyan,&p1-score,&p1-date,&p1-Melepeo); printf(課程編號 課程名稱 課程性質 總學時 授課學時 實驗學時 學分 開課學期 人數(shù)上限n);fprintf(stdout,%dt %st%st %dt%dt%dt%dt%dt%dn,p1-num1,p1-name1,p1-xin
11、zhi,p1-ztime,p1-stime,p1-shiyan,p1-score,p1-date,p1-Melepeo); head1=NULL; while(!feof(fp) N1=N1+1; if(N1=1)head1=p1; else p2-next=p1; p2=p1; p1=(struct couse * )malloc(sizeof(struct couse); fscanf(fp,%d%s%s%d%d%d%d%d,&p1-num1,p1-name1,&p1-xinzhi,&p1-ztime,&p1-stime,&p1-shiyan,&p1-score,&p1-date,&p1-
12、Melepeo);fprintf(stdout,%d %s %s %d %d %d %d %d %dn,p1-num1,p1-name1,p1-xinzhi,p1-ztime,p1-stime,p1-shiyan,p1-score,p1-date,p1-Melepeo); p2-next=NULL;void inputc()/錄入課程主函數(shù) int i; printf(ttt錄入課程信息n); printf(n1.從鍵盤錄入n); printf(2.從文件錄入n); printf(3.返回主菜單n); printf(請選擇(13):n); scanf(%d,&i); switch(i) cas
13、e(1):keyboardc();break; case(2):filec();break; case(3):break; void insertc(struct couse *incouse)/課程管理子函數(shù)(增加課程) struct couse *p0,*p1,*p2; p1=head1; p0=incouse; if(head1=NULL) head1=p0; p0-next=NULL; else while(p0-num1 p1-num1) & (p1-next!=NULL) p2=p1; p1=p1-next; if(p0-num1 num1) if(head1=p1) head1=
14、p0; else p2-next=p0; p0-next=p1; else p1-next=p0; p0-next=NULL; N1=N1+1;void delc(int num1)/課程管理子函數(shù)(刪除課程) struct couse *p1,*p2; if(head1=NULL) printf(n沒有課程,無法刪除!n); goto end; p1=head1; while(num1!=p1-num1 & p1-next!=NULL) p2=p1; p1=p1-next; if(num1=p1-num1) if(p1=head1) head1=p1-next; else p2-next=p
15、1-next; printf(已刪除該編號課程!n); N1=N1-1; else printf(無該編號的課程!n); end:;void managementc()/課程管理主函數(shù) struct couse * incouse; int i,num1; printf(ttt課程管理n); printf(1.新增課程n); printf(2.刪除課程n); printf(3.返回主菜單n); printf(請選擇(13):n); scanf(%d,&i); switch(i) case(1): incouse=(struct couse *)malloc(sizeof(struct cous
16、e); printf(課程編號 課程名稱 課程性質 總學時 授課學時 實驗學時 學分 開課學期 人數(shù)上限n); scanf(%dn%sn%sn%dn%dn%dn%dn%dn%dn,&incouse-num1,&incouse-name1,&incouse-xinzhi,&incouse-ztime,&incouse-stime,&incouse-score,&incouse-date,&incouse-Melepeo); incouse-nelepeo=0; insertc(incouse); break; case(2): printf(請輸入要刪除課程的編號:n); scanf(%d,&n
17、um1); delc(num1); break; case(3):break; void keyboards()/錄入學生信息子函數(shù)(從鍵盤錄入) int i; struct student *p1,*p2; N2=0; p1=p2=(struct student *)malloc(sizeof(struct student); printf(學生學號t學生姓名n); scanf(%d%s,&p1-num2,p1-name2); p1-nelen=0; for(i=0;inelenumi=0; head2=NULL; while(p1-num2!=0) N2=N2+1; if(N2=1)hea
18、d2=p1; else p2-next=p1; p2=p1; p1=(struct student * )malloc(sizeof(struct student); scanf(%d%s,&p1-num2,p1-name2); p1-nelen=0; for(i=0;inelenumi=0; p2-next=NULL;void files()/錄入學生信息子函數(shù)(從文件錄入) int i=0; FILE * fp; char filepath20; struct student *p1,*p2; N2=0; printf(輸入要讀入的文件路徑:); getchar(); gets(filep
19、ath); if(fp=fopen(filepath,r)=NULL) printf(找不到%s文件!n,filepath); exit(0); p1=p2=(struct student*)malloc(sizeof(struct student); fread(p1,sizeof(struct student),1,fp); head2=NULL; while(!feof(fp) i=0; N2=N2+1; if(N2=1)head2=p1; else p2-next=p1; p2=p1; p1=(struct student * )malloc(sizeof(struct student
20、); fread(p1,sizeof(struct student),1,fp); p2-next=NULL;void inputs()/錄入學生信息主函數(shù) int i; printf(ttt錄入學生信息n); printf(n1.從鍵盤錄入n); printf(2.從文件錄入n); printf(3.返回主菜單n); printf(請選擇(13):n); scanf(%d,&i); switch(i) case(1):keyboards();break; case(2):files();break; case(3):break; void inserts(struct student * i
21、ncouse)/學生信息管理子函數(shù)(填加學生信息) struct student *p0,*p1,*p2; p1=head2; p0=incouse; if(head2=NULL) head2=p0; p0-next=NULL; else while(p0-num2 p1-num2) & (p1-next!=NULL) p2=p1; p1=p1-next; if(p0-num2 num2) if(head2=p1) head2=p0; else p2-next=p0; p0-next=p1; else p1-next=p0; p0-next=NULL; N2=N2+1;void dels(in
22、t num2)/學生信息管理子函數(shù)(刪除學生信息) struct student *p1,*p2; if(head2=NULL) printf(n沒有該學生信息,無法刪除!n); goto end; p1=head2; while(num2!=p1-num2 & p1-next!=NULL) p2=p1; p1=p1-next; if(num2=p1-num2) if(p1=head2) head2=p1-next; else p2-next=p1-next; printf(已刪除該學生信息!n); N2=N2-1; else printf(無該學號的學生!n); end:;void mana
23、gements()/學生信息管理主函數(shù) struct student * incouse; int i,num2; printf(ttt學生信息管理n); printf(1.新增學生信息n); printf(2.刪除學生信息n); printf(3.返回主菜單n); printf(請選擇(13):n); scanf(%d,&i); switch(i) case(1): incouse=(struct student *)malloc(sizeof(struct student); incouse-nelen=0; incouse-nelenum0=0; printf(學生學號t學生姓名n);
24、scanf(%d%s,&incouse-num2,incouse-name2); inserts(incouse); break; case(2): printf(請輸入要刪除學生的學號:n); scanf(%d,&num2); dels(num2); break; case(3):break; void elect(struct student * s)/選課 struct couse * p; int num1,i; printf(請輸入要選課的編號:n); scanf(%d,&num1); for(i=0;s-nelenumi!=0;i+); s-nelenumi=num1; (s-ne
25、len)+; p=head1; while(p-num1!=num1) p=p-next; (p-nelepeo)+;void cheak()/學生選課子函數(shù)(查詢可選課程) char e; struct couse * c; struct student * s; int num2,i,j=0,t=0; printf(請輸入你的學號:); scanf(%d,&num2); s=head2; while(s-num2!=num2 & s-next!=NULL) s=s-next; if(s-num2!=num2) printf(不存在你的信息,請進入主菜單錄入你的信息!n); goto end
26、; c=head1; printf(你的可選課程編號:n); while(c!=NULL) for(t=0,i=0;s-nelenumi!=0;i+) if(c-num1=s-nelenumi) t=1; if(t=0 & (c-nelepeo!=c-Melepeo) printf(%dn,c-num1); j+; c=c-next; if(j=0) printf(你已選完所有課程,無法再多選!n); goto end; printf(選課(y/n)?:n); getchar(); e=getchar(); i=0; while(e=y) elect(s); printf(繼續(xù)選課(y/n)?
27、:n); getchar(); e=getchar(); end:;void back(struct student * p)/退課 struct couse * p1; int num1,i,j; printf(請輸入你要退掉的課程編號:n); scanf(%d,&num1); p1=head1; while(p1-num1!=num1) p1=p1-next; for(i=0;p-nelenumi!=num1;i+); for(j=i;p-nelenumj!=0;j+) p-nelenumj=p-nelenumj+1; p-nelenum-j=0; (p1-nelepeo)-; print
28、f(退課成功!n);void hcheak()/學生選課子函數(shù)(查詢已選課程) char c; struct couse * p0; struct student * p; int num2,i,f=0; printf(請輸入學號:n); scanf(%d,&num2); p=head2; while(p-num2!=num2 & p!=NULL) p=p-next; if(p=NULL) printf(不存在你的信息,請回主菜單錄入信息:n); goto end; printf(已選課程編號:n); if(p-nelenum0=0) printf(你還沒選課!n); goto end; fo
29、r(i=0;p-nelenumi!=0;i+) printf(%dn,p-nelenumi); p0=head1; while(p0-num1!=p-nelenumi) p0=p0-next; f=f+p0-score; printf(總學分:%dn,f); printf(是否進行退課(y/n)?); getchar(); c=getchar(); while(c=y) back(p); printf(繼續(xù)退課(y/n)?); getchar(); c=getchar(); (p-nelen)-; end:;void elective()/學生選課主函數(shù) int i; printf(ttt學生
30、選課n); printf(1.查詢可選課程n); printf(2.查詢已選課程n); printf(3.返回主菜單n); printf(請輸入(13):n); scanf(%d,&i); switch(i) case(1):cheak();break; case(2):hcheak();break; case(3):break; void listc()/輸出課程信息 struct couse * p; p=head1; printf(課程編號 名稱 性質 總學時 授課學時 實驗學時 學分 開課學期 已選人數(shù) 人數(shù)上限n); while(p!=NULL) printf(%d %s %s %d
31、 %d %d %d %d %d %dn,p-num1,p-name1,p-xinzhi,p-ztime,p-stime,p-shiyan,p-score,p-date,p-nelepeo,p-Melepeo); p=p-next; void lists()/輸出學生信息 struct student * p; p=head2; printf(學生學號 學生姓名 已選課程數(shù)量n); while(p!=NULL) printf(%-4d %10s %6dn,p-num2,p-name2,p-nelen); p=p-next; void intoc()/存儲課程信息 FILE * fp; struc
32、t couse * p; char filepath30; printf(輸入課程信息要保存的文件路徑:); getchar(); gets(filepath); if(fp=fopen(filepath,w)=NULL) printf(n保存失敗!); exit(0); p=head1; while(p!=NULL) fprintf(fp,%d %s %s %d %d %d %d %d %d %dn,p-num1,p-name1,p-xinzhi,p-ztime,p-stime,p-shiyan,p-score,p-date,p-nelepeo,p-Melepeo); p=p-next; f
33、close(fp); printf(課程信息已保存在%s中!n,filepath); void intos()/存儲學生信息 FILE * fp; struct student * p; char filepath30; printf(輸入學生信息要保存的文件路徑:); getchar(); gets(filepath); if(fp=fopen(filepath,w)=NULL) printf(n保存失敗!); exit(0); p=head2; while(p!=NULL) fwrite(p,sizeof(struct student),1,fp); p=p-next; fclose(fp); printf(學生信息已保存在%s中!
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 生態(tài)論文期刊
- 養(yǎng)殖場建設包工合同
- 生物基化工產品-洞察及研究
- 無害化處理新方法-洞察及研究
- 資源閉環(huán)優(yōu)化在智能制造中的應用研究-洞察闡釋
- 植物病原體相互作用的系統(tǒng)學研究-洞察闡釋
- 多模態(tài)縮進文本數(shù)據(jù)增強技術探索-洞察闡釋
- 2025-2030中國殯葬服務行業(yè)全產業(yè)深度調研與投資效益分析報告
- 2025年醫(yī)用電子儀器設備項目提案報告
- 混合學習模式下的教學模式創(chuàng)新與實踐-洞察闡釋
- 公司末梢裝維人員星級評定方案寬帶裝維星級評定
- 2025長城汽車人才測評答案
- 幼小銜接寫字教學安排
- 2025四川省安全員B證考試題庫
- 消防工程專項竣工驗收監(jiān)理質量評估報告
- 駕駛員安全月試題及答案
- 科技創(chuàng)新與中國特色社會主義理論的結合心得體會
- 反假幣上崗資格證書培訓考試題庫
- 2024年中考模擬試卷道法(北京卷)
- 2025年上半年某縣消防大隊工作總結(二篇)
- 2025屆高考英語復習讀后續(xù)寫練習:紙報停刊后少年開啟鄰里簡報之路+課件
評論
0/150
提交評論