學(xué)生選課系統(tǒng)C語言程序代碼_第1頁
學(xué)生選課系統(tǒng)C語言程序代碼_第2頁
學(xué)生選課系統(tǒng)C語言程序代碼_第3頁
已閱讀5頁,還剩22頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、#include #includestruct couse * headl;struct student * head2;struct couse /課程信息結(jié)構(gòu)體int numl;char name120;int score;int nelepeo;/課程已選人數(shù)int Melepeo;/課程人數(shù)上限struct couse * next;struct student /學(xué)生信息結(jié)構(gòu)體int num2;char name220;int nelenum50; /已選課程編號int nelen; /已選課程數(shù)量struct student * next;void keyboardc() /錄入課

2、程子函數(shù)(從鍵盤錄入)struct couse *p1,*p2;N1=0;p1=p2=(struct couse*)malloc(sizeof(struct couse);printf(n課程編號t課程名稱t學(xué)分t課程人數(shù)上限n);scanf(%d%s%d%d,&p1-num1,p1-name1,&p1-score,&p1-Melepeo);p1-nelepeo=0;head 仁NULL;while(p1-num1!=0&p1-num1!=#)N1=N1+1;if(N1=1)head 1= p1;else p2-next=p1;p2=p1;p1=(struct couse * )malloc(

3、sizeof(struct couse);scanf(%d%s%d%d,&p1-num1,p1-name1,&p1-score,&p1-Melepeo);p1-nelepeo=0;p2-next=NULL;void inputc() /錄入課程主函數(shù)int i;printf(n錄入課程信息n);printf(n1.從鍵盤錄入 n);printf(n2.返回主菜單 n);printf(n請選擇編號(13):n);scanf(%d,&i);switch(i)case(1):keyboardc();break;case(2):break;/課程信息增加子void insertc(struct cou

4、se *incouse)函數(shù)struct couse *p0,*p1,*p2;p1=head1;p0=incouse;if(head1=NULL)head1=pO;pO-next=NULL;elsewhile(pO-num1p1-num1)&(p1-next!=NULL)p2=p1;p1=p1- n ext;if(p0-num1 num1)if(head 1=p1) head 1= p0;else p2-next=p0;p0-n ext=p1;elsep1-next=pO;N1=N1+1;void delc(int numl) /課程信息刪除子函數(shù)struct couse *p1,*p2;if

5、(head1=NULL)printf(n沒有課程,無法刪除!n);goto end;p1=head1;while(num1!=p1-num1 & p1-next!=NULL)p2=p1;p1=p1- n ext;if(num1=p1-num1)if(p1=head1) head仁p1-next;printf(n已刪除該編號課程!n);N1=N1 -1;else printf(n無該編號的課程!n);end:;void management)/課程信息管理主函數(shù)struct couse * incouse;int i,num1;printf(n課程管理n);printf(n1.新增課程n);pr

6、intf(n2.刪除課程n);printf(n3.返回主菜單n);printf(n請選擇編號(13):scanf(%d,&i);switch(i)cousecase(1):incouse=(struct*)malloc(sizeof(struct couse);printf(n課程編號t課程名稱t學(xué)分t課程人數(shù)上限n);scanf(%d%s%d%d,&i ncouse-num1,incouse-name1,&inc ouse-score,&i ncouse-Melepeo);incouse-nelepeo=0;insertc(incouse);break;case(2):printf(n請輸入

7、要刪除課程的編號:n);scanf(%d,&num1);delc(num1);break;case(3):break;void keyboards。/錄入學(xué)生信息子函數(shù)(從鍵盤錄入)int i;struct student *p1,*p2;N2=0;p1=p2=(structstudent *)malloc(sizeof(structstudent);printf(n學(xué)生學(xué)號t學(xué)生姓名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=

8、1)head2=p1;else p2-next=p1;p2=p1;p1=(structstudent * )malloc(sizeof(structstudent);scanf(%d%s,&p1-num2,p1-name2);p1-nelen=0;for(i=0;inelenumi=0;p2-next=NULL;void inputs() /錄入學(xué)生信息主函數(shù)int i;printf(n錄入學(xué)生信息n);printf(n1.從鍵盤錄入 n);printf(n2.返回主菜單 n);printf(n請選擇編號(12):n);scanf(%d,&i);switch(i)case(1):keyboar

9、ds();break;case(2):break;/學(xué)生信息增加void inserts(struct student * incouse)子函數(shù)struct student *p0,*p1,*p2;p仁head2;p0=incouse;if(head2=NULL)head2=p0;pO-next=NULL;else&while(p0-num2p1-num2)(pl- next!=NULL)p2=p1;p1=p1- n ext;if(p0-num2 num2)if(head2=p1) head2=p0;else p2-next=p0;p0-n ext=p1;elsep1-next=pO;N2=

10、N2+1;void dels(int num2) /學(xué)生信息刪除子函數(shù)struct student *p1,*p2;if(head2=NULL)printf(n沒有該學(xué)生信息,無法刪除!n);goto end;p仁head2;while(num2!=p1-num2 & p1-next!=NULL)p2=p1;p1=p1- n ext;if(num2=p1-num2)if(p1=head2) head2=p1-next;printf(n已刪除該學(xué)生信息!n);N2=N2-1;else printf(n無該學(xué)號的學(xué)生!n);end:;void managements。/學(xué)生信息管理主函數(shù)struc

11、t student * incouse;int i,num2;printf(n學(xué)生信息管理n);printf(n1.新增學(xué)生信息n);printf(n2.刪除學(xué)生信息n);printf(n3.返回主菜單n);printf(n請選擇編號(13):nscanf(%d,&i);switch(i)studentcase(1):incouse=(struct*)malloc(sizeof(struct student);incouse-nelen=0;incouse-nelenum0=0;printf(n學(xué)生學(xué)號t學(xué)生姓名n);scanf(%d%s,&incouse-num2,incouse-name2

12、);inserts(incouse);break;case(2):printf(n請輸入要刪除學(xué)生的學(xué)號:n);scanf(%d,&num2);dels(num2);break;case(3):break;void elect(struct student * s)/ 學(xué)生選課子函數(shù)(進行選課)struct couse * p;int num1,i;printf(n 請輸入要選課的編號:n);scanf(%d,&num1);for(i=0;s-n ele nu mi!=0;i+);s-nelenumi=num1;(s-n ele n)+;p=head1;while(p-num1!=num1)

13、p=p-next;(p-n elepeo)+;void cheak() /學(xué)生選課子函數(shù)(查詢可選課程)char e;struct couse * c;struct student * s;int num2,i,j=0,t=0;printf(n 請輸入你的學(xué)號:n);scanf(%d,&num2);s=head2;while(s-num2!=num2 & s-next!=NULL) s=s-next;if(s-num2!=num2)不存在你的信息,請進入主菜單錄入你printf(n的信息!n);goto end;c=head1;printf(n你的可選課程編號:n);while(c!=NULL

14、)for(t=0,i=0;s-n ele nu mi!=0;i+)if(c-num1=s-nelenumi) t=1;if(t=0 & (c-nelepeo!=c-Melepeo)printf(%d ,c-num1);j+;c=c-next;if(j=0)printf(n你已選完所有課程,無法再多選!n);goto end;printf(n 選課(y/n)?:n);getchar();e=getchar();i=0;while(e=y)elect(s);printf(n繼續(xù)選課(y/n)?:n);getchar();e=getchar();end:;void back(struct stude

15、nt * p)/退選課程struct couse * p1;int num1,i,j;printf(n請輸入你要退掉的課程編號:n);scanf(%d,&num1);p仁headl;while(p1-num1!=num1) p1=p1-next;for(i=0;p-n ele nu mi!=nu m1;i+);for(j=i;p-n ele nu mj!=O;j+)p-nelenumj=p-nelenumj+1;p-nelenum-j=0;(p1- n elepeo)-;printf(n退課成功!n);void hcheak() /學(xué)生選課子函數(shù)(查詢已選課程)char c;struct co

16、use * p0;struct student * p;int num2,i,f=0;printf(n請輸入學(xué)號:n);scanf(%d,&num2);p=head2;while(p-num2!=num2 & p!=NULL) p=p-next;if(p=NULL)printf(n不存在你的信息,請回主菜單錄入信息:n);goto end;printf(n已選課程編號:n);if(p-nelenum0=0)printf(n你還沒選課!n);goto end;for(i=0;p-n ele nu mi!=0;i+)printf(%dn,p-nelenumi);p0=head1;while(p0-

17、num1!=p-nelenumi) pO=pO-next; f=f+pO-score;printf(n總學(xué)分:%dn,f);printf(n是否進行退課(y/n)?n);getchar();c=getchar();while(c=y)back(p);printf(n繼續(xù)退課(y/n)?);getchar();c=getchar();(p-n ele n)-;end:;void elective() /學(xué)生選課主函數(shù)int i;學(xué)生選課n);查詢可選課程n);查詢已選課程n);返回主菜單n);請輸入(13):n);printf(nprintf(n1.printf(n2.printf(n3. pr

18、intf(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(n課程編號課程名稱學(xué)分課程已選人數(shù) 課程人數(shù)上限n);while(p!=NULL) printf(%-8d%10s%6d%8d%12dn,p-num1,p-name1,p-s core,p-nelepeo,p-Melepeo);p=p-n ext;void lists() /查看學(xué)生信息struct student *

19、 p;p=head2;printf(n學(xué)生學(xué)號學(xué)生姓名已選課程數(shù)量n);while(p!=NULL)printf(%-4d %10s %6dn,p-num2,p-name2,p-nelen); p=p-n ext;void store() /系統(tǒng)信息查看主函數(shù)int i;printf(n系統(tǒng)信息查看n);printf(n1.查看課程信息n);printf(n2.查看學(xué)生信息n);printf(n3.返回主菜單n);printf(n請輸入編號(13):nscanf(%d,&i);switch(i)case(1):listc();break;case(2):lists();break; case(3):break;int main()

溫馨提示

  • 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論