![學生選課系統(tǒng)程序設計_第1頁](http://file4.renrendoc.com/view/3e52b33bfed30cc8aec090c7ae15aaa4/3e52b33bfed30cc8aec090c7ae15aaa41.gif)
![學生選課系統(tǒng)程序設計_第2頁](http://file4.renrendoc.com/view/3e52b33bfed30cc8aec090c7ae15aaa4/3e52b33bfed30cc8aec090c7ae15aaa42.gif)
![學生選課系統(tǒng)程序設計_第3頁](http://file4.renrendoc.com/view/3e52b33bfed30cc8aec090c7ae15aaa4/3e52b33bfed30cc8aec090c7ae15aaa43.gif)
![學生選課系統(tǒng)程序設計_第4頁](http://file4.renrendoc.com/view/3e52b33bfed30cc8aec090c7ae15aaa4/3e52b33bfed30cc8aec090c7ae15aaa44.gif)
![學生選課系統(tǒng)程序設計_第5頁](http://file4.renrendoc.com/view/3e52b33bfed30cc8aec090c7ae15aaa4/3e52b33bfed30cc8aec090c7ae15aaa45.gif)
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
根據自己的需要,自己看著修改一下AA#include<stdio.h>#include<stdlib.h>intN1,N2,kk1,kk2,kk3;structcouse*head1;structstudent*head2;structcouse//課程信息結構體{intnum1;charname1[20];intscore;intnelepeo;//課程已選人數intMelepeo;//課程人數上限structcouse*next;};structstudent〃學生信息結構體{intnum2;charname2[20];intnelenum[50];〃已選課程編號intnelen;〃已選課程數量structstudent*next;};voidMs(){for(kk1=0;kk1<1100;kk1++)for(kk2=0;kk2<1200;kk2++)for(kk3=0;kk3<1200;kk3++);}voidkeyboardc()〃錄入課程子函數(從鍵盤錄入){structcouse*p1,*p2;N1=0;p1=p2=(structcouse*)malloc(sizeof(structcouse));printf("課程編號\t課程名稱\t學分\t課程人數上限\n”);scanf("%d%s%d%d",&p1->num1,p1->name1,&p1->score,&p1->Melepeo);p1->nelepeo=0;head1=NULL;while(p1->num1!=0)N1=N1+1;if(N1==1)head1=p1;elsep2->next=p1;p2=p1;p1=(structcouse*)malloc(sizeof(structcouse));scanf("%d%s%d%d",&p1->num1,p1->name1,&p1->score,&p1->Melepeo);p1->nelepeo=0;}p2->next=NULL;}voidfilec()〃錄入鍵盤子函數(從文件錄入){FILE*fp;charfilepath[20];structcouse*p1,*p2;N1=0;printf(”輸入要讀入的文件路徑:”);getchar();gets(filepath);if((fp=fopen(filepath,"r"))==NULL){printf("找不到%s文件!\n”,filepath);exit(0);}p1=p2=(structcouse*)malloc(sizeof(structcouse));fscanf(fp,"%d%s%d%d%d",&p1->num1,p1->name1,&p1->score,&p1->nelepeo,&p1->Melepeo);head1=NULL;while(!feof(fp)){N1=N1+1;if(N1==1)head1=p1;elsep2->next=p1;p2=p1;p1=(structcouse*)malloc(sizeof(structcouse));fscanf(fp,"%d%s%d%d%d",&p1->num1,p1->name1,&p1->score,&p1->nelepeo,&p1->Melepeo);}p2->next=NULL;}voidinputc()〃錄入課程主函數inti;printf(”\t\t\t錄入課程信息\n”);printf("\n1.從鍵盤錄入\n”);printf("2?從文件錄入\n”);printf(”3.返回主菜單\n”);printf("請選擇(1~3):\n”);scanf("%d",&i);switch(i){case(1):keyboardc();break;case(2):filec();break;case(3):break;}}voidinsertc(structcouse*incouse)//課程管理子函數(增加課程){structcouse*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<=p1->num1){if(head1==p1)head1=p0;elsep2->next=p0;p0->next=p1;}elsep1->next=p0;p0->next=NULL;}}N1=N1+1;}voiddelc(intnum1)〃課程管理子函數(刪除課程){structcouse*p1,*p2;if(head1==NULL){printf("\n沒有課程,無法刪除!\n");gotoend;}p1=head1;while(num1!=p1->num1&&p1->next!=NULL){p2=p1;p1=p1->next;}if(num1==p1->num1){if(p1==head1)head1=p1->next;elsep2->next=p1->next;printf("已刪除該編號課程!\n”);N1=N1-1;}elseprintf(”無該編號的課程!\n”);end:;}voidmanagementc()〃課程管理主函數{structcouse*incouse;inti,num1;printf("\t\t\t課程管理\n”);printf(”1.新增課程\n”);printf("2柵0除課程\n”);printf(”3.返回主菜單\n”);printf("請選擇(1~3):\n”);scanf("%d",&i);switch(i){case(1):incouse=(structcouse*)malloc(sizeof(structcouse));printf(”課程編號\t課程名稱\t學分\t課程人數上限\n”);scanf("%d%s%d%d",&incouse->num1,incouse->name1,&incouse->score,&incouse->Melepeo);incouse->nelepeo=0;insertc(incouse);break;}case(2):{printf(”請輸入要刪除課程的編號:\n");scanf("%d",&num1);delc(num1);break;}case(3):break;}}voidkeyboards。//錄入學生信息子函數(從鍵盤錄入){inti;structstudent*p1,*p2;N2=0;p1=p2=(structstudent*)malloc(sizeof(structstudent));printf(”學生學號\t學生姓名\n”);scanf("%d%s",&p1->num2,p1->name2);p1->nelen=0;for(i=0;i<20;i++)p1->nelenum[i]=0;head2=NULL;while(p1->num2!=0){N2=N2+1;if(N2==1)head2=p1;elsep2->next=p1;p2=p1;p1=(structstudent*)malloc(sizeof(structstudent));scanf("%d%s",&p1->num2,p1->name2);p1->nelen=0;for(i=0;i<20;i++)p1->nelenum[i]=0;}p2->next=NULL;}voidfiles()〃錄入學生信息子函數(從文件錄入){inti=0;FILE*fp;charfilepath[20];structstudent*p1,*p2;N2=0;printf(”輸入要讀入的文件路徑:”);getchar();gets(filepath);if((fp=fopen(filepath,"r"))==NULL){printf("找不到%s文件!\n”,filepath);exit(0);}p1=p2=(structstudent*)malloc(sizeof(structstudent));fread(p1,sizeof(structstudent),1,fp);head2=NULL;while(!feof(fp)){i=0;N2=N2+1;if(N2==1)head2=p1;elsep2->next=p1;p2=p1;p1=(structstudent*)malloc(sizeof(structstudent));fread(p1,sizeof(structstudent),1,fp);}p2->next=NULL;}voidinputs()〃錄入學生信息主函數{inti;printf("\t\t\t錄入學生信息\n”);printf("\n1.從鍵盤錄入\n”);printf("2?從文件錄入\n”);printf(”3.返回主菜單\n”);printf("請選擇(1~3):\n”);scanf("%d",&i);switch(i)case(1):keyboards();break;case(2):files();break;case(3):break;}}voidinserts(structstudent*incouse)//學生信息管理子函數(填加學生信息){structstudent*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<=p1->num2){if(head2==p1)head2=p0;elsep2->next=p0;p0->next=p1;}else{p1->next=p0;p0->next=NULL;}}N2=N2+1;}voiddels(intnum2)〃學生信息管理子函數(刪除學生信息){structstudent*p1,*p2;if(head2==NULL)printf("\n沒有該學生信息,無法刪除!\n");gotoend;}p1=head2;while(num2!=p1->num2&&p1->next!=NULL){p2=p1;p1=p1->next;}if(num2==p1->num2){if(p1==head2)head2=p1->next;elsep2->next=p1->next;printf("已刪除該學生信息!\n");N2=N2-1;}elseprintf(”無該學號的學生!\n”);end:;}voidmanagements()〃學生信息管理主函數{structstudent*incouse;inti,num2;printf("\t\t\t學生信息管理\n");printf("1.新增學生信息\n”);printf("2柵0除學生信息\n”);printf(”3.返回主菜單\n”);printf("請選擇(1~3):\n”);scanf("%d",&i);switch(i){case(1):{incouse=(structstudent*)malloc(sizeof(structstudent));incouse->nelen=0;incouse->nelenum[0]=0;printf(”學生學號\t學生姓名\n”);scanf("%d%s",&incouse->num2,incouse->name2);inserts(incouse);break;}case(2):{printf(”請輸入要刪除學生的學號:\n”);scanf("%d",&num2);dels(num2);break;}case(3):break;}}voidelect(structstudent*s)〃選課{structcouse*p;intnum1,i;printf(”請輸入要選課的編號:\n");scanf("%d",&num1);for(i=0;s->nelenum[i]!=0;i++);s->nelenum[i]=num1;(s->nelen)++;p=head1;while(p->num1!=num1)p=p->next;(p->nelepeo)++;}voidcheak()〃學生選課子函數(查詢可選課程){chare;structcouse*c;structstudent*s;intnum2,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");gotoend;}c=head1;printf(”你的可選課程編號:\n");while(c!=NULL)for(t=0,i=0;s->nelenum[i]!=0;i++){if(c->num1==s->nelenum[i])t=1;}if(t==0&&(c->nelepeo!=c->Melepeo)){printf("%d\n",c->num1);j++;}c=c->next;}if(j==0){printf(”你已選完所有課程,無法再多選!\n”);gotoend;}printf(”選課(y/n)?:\n”);getchar();e=getchar();i=0;while(e=='y'){elect(s);printf("繼續(xù)選課(y/n)?:\n”);getchar();e=getchar();}end:;}voidback(structstudent*p)〃退課{structcouse*p1;intnum1,i,j;printf("請輸入你要退掉的課程編號:\n");scanf("%d",&num1);p1=head1;while(p1->num1!=num1)p1=p1->next;for(i=0;p->nelenum[i]!=num1;i++);for(j=i;p->nelenum[j]!=0;j++)p->nelenum[j]=p->nelenum[j+1];p->nelenum[--j]=0;(p1->nelepeo)--;printf("退課成功!\n”);}voidhcheak()〃學生選課子函數(查詢已選課程)charc;structcouse*p0;structstudent*p;intnum2,i,f=0;printf(”請輸入學號:\n");scanf("%d",&num2);p=head2;while(p->num2!=num2&&p!=NULL)p=p->next;if(p==NULL){printf(”不存在你的信息,請回主菜單錄入信息:\n");gotoend;}printf("已選課程編號:\n”);if(p->nelenum[0]==0){printf("你還沒選課!\n”);gotoend;}for(i=0;p->nelenum[i]!=0;i++){printf("%d\n",p->nelenum[i]);p0=head1;while(p0->num1!=p->nelenum[i])p0=p0->next;f=f+p0->score;}printf("總學分:%d\n",f);printf("是否進行退課(y/n)?”);getchar();c=getchar();while(c=='y'){back(p);printf("繼續(xù)退課(y/n)?");getchar();c=getchar();(p->nelen)--;}end:;}voidelective。//學生選課主函數inti;printf(”\t\t\t學生選課\n”);printf("1.查詢可選課程\n”);printf("2.查詢已選課程\n”);printf(”3.返回主菜單\n”);printf("請輸入(1~3):\n");scanf("%d",&i);switch(i){case(1):cheak();break;case(2):hcheak();break;case(3):break;}}voidlistc()〃輸出課程信息{structcouse*p;p=head1;printf("課程編號課程名稱學分課程已選人數課程人數上限\n");while(p!=NULL){printf("%-8d%10s%6d%8d%12d\n",p->num1,p->name1,p->score,p->nelepeo,p->Melepeo);p=p->next;}}voidlists()〃輸出學生信息{structstudent*p;p=head2;printf("學生學號學生姓名已選課程數量\n");while(p!=NULL){printf("%-4d%10s%6d\n",p->num2,p->name2,p->nelen);p=p->next;}}voidintoc()〃存儲課程信息{FILE*fp;structcouse*p;charfilepath[30];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%d\n",p->num1,p->name1,p->score,p->nelepeo,p->Melepeo);p=p->next;}fclose(fp);printf("課程信息已保存在%$中!\n”,filepath);}voidintos()〃存儲學生信息{FILE*fp;structstudent*p;charfilepath[30];printf("輸入學生信息要保存的文件路徑門;getchar();gets(filepath);if((fp=fopen(filepath,"w"))==NULL){printf("\n保存失敗!");exit(0);}p=head2;while(p!=NULL){fwrite(p,sizeof(structstudent),1,fp);p=p->next;}fclose(fp);printf("學生信息已保存在%s中!\n",filepath);}voidinto()〃存儲信息{inti;printf("1.存儲課程信息\n");printf("2?存儲學生信息\n");printf(”3.返回主菜單\n”);printf("請輸入(1~3)\n");scanf("%d",&i);switch(i){case(1):intoc();break;case(2):intos();break;case(3):break;}}voidstore()〃信息主函數{inti;printf("\t\t系統(tǒng)信息查看及存儲\n");printf("1.查看課程信息\n");printf("2?查看學生信息\n");pr
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年分銷合同版權聲明
- 2025年建筑招投標合同
- 職業(yè)教育居間合同委托書
- 花藝店裝修免租合同樣本
- 證券投資居間代理合同
- 旅游景區(qū)智慧化升級建設投資合同
- 年度城市形象宣傳策劃合同
- 確認深圳至廣州跨境貿易采購合同
- 環(huán)保能源技術引進合同
- 法律咨詢服務合同書
- 內燃機車鉗工(中級)職業(yè)鑒定理論考試題及答案
- 長期處方管理規(guī)范-學習課件
- 高中英語外研版 單詞表 選擇性必修3
- 中小學校園突發(fā)事件應急與急救處理課件
- 2024年山東省普通高中學業(yè)水平等級考試生物真題試卷(含答案)
- 2024年青海省西寧市選調生考試(公共基礎知識)綜合能力題庫匯編
- 2024年湖南高速鐵路職業(yè)技術學院單招職業(yè)技能測試題庫及答案解析
- 廣州綠色金融發(fā)展現狀及對策的研究
- 《近現代史》義和團運動
- 時間的重要性英文版
- 2024老舊小區(qū)停車設施改造案例
評論
0/150
提交評論