學(xué)生選課系統(tǒng)代碼互聯(lián)網(wǎng)_第1頁
學(xué)生選課系統(tǒng)代碼互聯(lián)網(wǎng)_第2頁
學(xué)生選課系統(tǒng)代碼互聯(lián)網(wǎng)_第3頁
學(xué)生選課系統(tǒng)代碼互聯(lián)網(wǎng)_第4頁
學(xué)生選課系統(tǒng)代碼互聯(lián)網(wǎng)_第5頁
已閱讀5頁,還剩10頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、#include #includeint n1,n2,kk1,kk2,kk3;struct couse * head1;struct student * head2;struct couseint num1;char name120;int score;int nelepeo;int melepeo;struct couse * next;struct studentint num2;char name220;int nelenum50;int nelen;struct student * next;void ms()for(kk1=0;kk11100;kk1+)for(kk2=0;kk212

2、00;kk2+)for(kk3=0;kk3num1,p1-name1,&p1-score,&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%d%d,&p1-num1,p1-name1,&p1-score,&p1-melepeo);p1-nelepeo=0;p2-next=null;void filec()file * fp;ch

3、ar filepath20; struct couse *p1,*p2;n1=0;printf(輸入要讀入的文件路徑:);getchar();gets(filepath); if(fp=fopen(filepath,r)=null) printf(找不到%s文件!n,filepath); exit(0); p1=p2=(struct couse*)malloc(sizeof(struct couse);fscanf(fp,%d%s%d%d%d,&p1-num1,p1-name1,&p1-score,&p1-nelepeo,&p1-melepeo);head1=null;while(!feof(

4、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%d%d%d,&p1-num1,p1-name1,&p1-score,&p1-nelepeo,&p1-melepeo); p2-next=null;void inputc() int i;printf(ttt錄入課程信息n); printf(n1.從鍵盤錄入n);printf(2.從文件錄入n);printf(3.返回主菜單n);printf(請(qǐng)選擇(13):n); sc

5、anf(%d,&i);switch(i)case(1):keyboardc();break;case(2):filec();break;case(3):break;void insertc(struct couse *incouse)struct couse *p0,*p1,*p2;p1=head1;p0=incouse;if(head1=null)head1=p0; p0-next=null;elsewhile(p0-num1 p1-num1) & (p1-next!=null) p2=p1; p1=p1-next; if(p0-num1 num1) if(head1=p1) head1=p

6、0; else p2-next=p0; p0-next=p1; else p1-next=p0;p0-next=null;n1=n1+1;void delc(int num1)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=p1-next;printf(已刪除該編號(hào)課程!n

7、);n1=n1-1;else printf(無該編號(hào)的課程!n);end:;void managementc()struct couse * incouse;int i,num1;printf(ttt課程管理n);printf(1.新增課程n);printf(2.刪除課程n);printf(3.返回主菜單n);printf(請(qǐng)選擇(13):n);scanf(%d,&i);switch(i)case(1):incouse=(struct couse *)malloc(sizeof(struct couse);printf(課程編號(hào)t課程名稱t學(xué)分t課程人數(shù)上限n); scanf(%d%s%d%d

8、,&incouse-num1,incouse-name1,&incouse-score,&incouse-melepeo);incouse-nelepeo=0;insertc(incouse);break;case(2):printf(請(qǐng)輸入要?jiǎng)h除課程的編號(hào):n);scanf(%d,&num1);delc(num1);break;case(3):break;void keyboards()int i;struct student *p1,*p2;n2=0;p1=p2=(struct student *)malloc(sizeof(struct student);printf(學(xué)生學(xué)號(hào)t學(xué)生姓名

9、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)head2=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()int i=0;file * fp;char

10、filepath20; struct student *p1,*p2;n2=0;printf(輸入要讀入的文件路徑:);getchar();gets(filepath); 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;e

11、lse p2-next=p1;p2=p1;p1=(struct student * )malloc(sizeof(struct student);fread(p1,sizeof(struct student),1,fp); p2-next=null;void inputs()int i;printf(ttt錄入學(xué)生信息n);printf(n1.從鍵盤錄入n);printf(2.從文件錄入n);printf(3.返回主菜單n);printf(請(qǐng)選擇(13):n);scanf(%d,&i);switch(i)case(1):keyboards();break;case(2):files();bre

12、ak;case(3):break;void inserts(struct student * incouse)struct student *p0,*p1,*p2;p1=head2;p0=incouse;if(head2=null)head2=p0;p0-next=null;elsewhile(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;elsep1-next=p0;p0-next=null;n2=n2+1;

13、void dels(int num2)struct student *p1,*p2;if(head2=null)printf(n沒有該學(xué)生信息,無法刪除!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(已刪除該學(xué)生信息!n);n2=n2-1;else printf(無該學(xué)號(hào)的學(xué)生!n);end:;void managements()struct stude

14、nt * incouse;int i,num2;printf(ttt學(xué)生信息管理n);printf(1.新增學(xué)生信息n);printf(2.刪除學(xué)生信息n);printf(3.返回主菜單n);printf(請(qǐng)選擇(13):n);scanf(%d,&i);switch(i)case(1):incouse=(struct student *)malloc(sizeof(struct student);incouse-nelen=0;incouse-nelenum0=0;printf(學(xué)生學(xué)號(hào)t學(xué)生姓名n);scanf(%d%s,&incouse-num2,incouse-name2);insert

15、s(incouse);break;case(2):printf(請(qǐng)輸入要?jiǎng)h除學(xué)生的學(xué)號(hào):n);scanf(%d,&num2);dels(num2);break;case(3):break;void elect(struct student * s)struct couse * p;int num1,i;printf(請(qǐng)輸入要選課的編號(hào):n);scanf(%d,&num1);for(i=0;s-nelenumi!=0;i+);s-nelenumi=num1;(s-nelen)+;p=head1;while(p-num1!=num1) p=p-next; (p-nelepeo)+;void che

16、ak()char e;struct couse * c;struct student * s;int num2,i,j=0,t=0;printf(請(qǐng)輸入你的學(xué)號(hào):);scanf(%d,&num2);s=head2;while(s-num2!=num2 & s-next!=null) s=s-next;if(s-num2!=num2)printf(不存在你的信息,請(qǐng)進(jìn)入主菜單錄入你的信息!n);goto end;c=head1;printf(你的可選課程編號(hào):n);while(c!=null)for(t=0,i=0;s-nelenumi!=0;i+)if(c-num1=s-nelenumi) t

17、=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)?:n);getchar();e=getchar();end:;void back(struct student * p)struct couse * p1;int num1,i,j;printf(請(qǐng)輸入你要退掉的課程編號(hào):n

18、);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)-;printf(退課成功!n);void hcheak()char c;struct couse * p0;struct student * p;int num2,i,f=0;printf(請(qǐng)輸入學(xué)號(hào):n);scanf(%d,&num2);p=head2;while(

19、p-num2!=num2 & p!=null) p=p-next;if(p=null)printf(不存在你的信息,請(qǐng)回主菜單錄入信息:n);goto end;printf(已選課程編號(hào):n);if(p-nelenum0=0)printf(你還沒選課!n);goto end;for(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(總學(xué)分:%dn,f);printf(是否進(jìn)行退課(y/n)?);getchar();c=ge

20、tchar();while(c=y)back(p);printf(繼續(xù)退課(y/n)?);getchar();(p-nelen)-;end:;void elective()int i;printf(ttt學(xué)生選課n);printf(1.查詢可選課程n);printf(2.查詢已選課程n);printf(3.返回主菜單n);printf(請(qǐng)輸入(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;pr

21、intf(課程編號(hào) 課程名稱 學(xué)分 課程已選人數(shù) 課程人數(shù)上限n);while(p!=null)printf(%-8d%10s%6d%8d%12dn,p-num1,p-name1,p-score,p-nelepeo,p-melepeo);p=p-next;void lists()struct student * p;p=head2;printf(學(xué)生學(xué)號(hào) 學(xué)生姓名 已選課程數(shù)量n);while(p!=null)printf(%-4d %10s %6dn,p-num2,p-name2,p-nelen);p=p-next;void intoc()file * fp;struct couse * p

22、;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 %d %d %dn,p-num1,p-name1,p-score,p-nelepeo,p-melepeo);p=p-next;fclose(fp); printf(課程信息已保存在%s中!n,filepath); void intos()file * fp;struct s

23、tudent * p;char filepath30; printf(輸入學(xué)生信息要保存的文件路徑:);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(學(xué)生信息已保存在%s中!n,filepath); void into()int i;printf(1.存儲(chǔ)課程信息n);printf(2.存儲(chǔ)學(xué)生信息n);printf(3.返回主菜單n);printf(請(qǐng)輸入(13)n);scanf(%d,&i);switch(i)case(1):intoc();break;case(2):intos();break;case(3):break; void store()int i;printf(tt系統(tǒng)信息查看及存儲(chǔ)n);printf(1.查看課程信

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論