




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、#include#include#includeint N1,N2;struct studentint num2;char name220;int nelenum50; /int nelen;/struct student * next;struct courseint num1; / 課程編號(hào)char name120;char major20;char type20;int credit;int period;char teacher20;int people;/struct course *next; /;struct course * head1;struct student * hea
2、d2;void zhang()/所選課程編號(hào)所選課程學(xué)分和選此門課程的人數(shù)結(jié)構(gòu)體指針從鍵盤錄入課程信息struct course *p1,*p2;N1=0;p1=p2=(struct course *)malloc(sizeof(struct course);printf( 課程編號(hào) t 課程名稱 t 主修 t 課程性質(zhì) t 學(xué)分 t 課時(shí) t 教師n);scanf(%d%s%s%s%d%d%s,&p1-num1,p1-name1,p1-major,p1-type,&p1-cr edit,&p1-period,p1-teacher);p1-people=0;head1=NULL;while(p
3、1-num1!=0)N1=N1+1;if(N1=1)head1=p1;else p2-next=p1;p2=p1;p1=(struct course * )malloc(sizeof(struct course);scanf(%d%s%s%s%d%d%s,&p1-num1,p1-name1,p1-major,p1-type,&p1-cr edit,&p1-period,p1-teacher);p1-people=0;p2-next=NULL;void zhang1()/從文件錄入課程信息FILE * fp;char filepath20;struct course *p1,*p2;N1=0;p
4、rintf( 請輸入您要讀取的路徑:);getchar();gets(filepath);if(fp=fopen(filepath,r)=NULL)printf( 找不到 %s 文件 !n,filepath);exit(0);p1=p2=(struct course*)malloc(sizeof(struct course);fscanf(fp,%d%s%s%s%d%d%s%d,&p1-num1,p1-name1,p1-major,p1-type,& p1-credit,&p1-period,p1-teacher,&p1-people);while(!feof(fp)N1=N1+1;if(N1
5、=1)head1=p1;elsep2-next=p1;p2=p1;p1=(struct course * )malloc(sizeof(struct course);fscanf(fp,%d%s%s%s%d%d%s%d,&p1-num1,p1-name1,p1-major,p1-type,& p1-credit,&p1-period,p1-teacher,&p1-people);p2-next=NULL;void load() /錄入課程信息函數(shù)int i;printf(ttt 錄入課程信息n);printf(n1.從鍵盤錄入);printf(n2.從文件錄入);printf(n3.返回主菜單
6、n);printf( 請選擇 1-3:);scanf(%d,&i);switch(i)case 1: zhang(); break;case 2:zhang1();break;case 3:break;void insert(struct course *incourse) /增加課程信息struct course *p0,*p1,*p2;p1=head1;p0=incourse;if(head1=NULL)head1=p0;p0-next=NULL;elsewhile(p0-num1p1-num1) & (p1-next!=NULL)p2=p1;p1=p1-next;if(p0-num1nu
7、m1)if(head1=p1)head1=p0;elsep2-next=p0;p0-next=p1;elsep1-next=p0;p0-next=NULL;N1=N1+1;void delc(int num1) /刪除課程信息struct course *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;elsep2-next=p1-next;p
8、rintf( 已刪除 n);N1=N1-1;elseprintf( 沒有此課程n);end:;void managementc() /課程信息管理函數(shù)struct course * p1;int i,num1;printf(ttt 課程信息管理n);printf(1.添加課程n);printf(2.刪除課程n);printf(3. 返回 n);printf( 請輸入 1-3:n);scanf(%d,&i);switch(i)case 1:p1=(struct course *)malloc(sizeof(struct course);printf( 課程編號(hào) t 課程名稱 t 主修 t 課程性
9、質(zhì) t 學(xué)分 t 課時(shí) t 教師 n);scanf(%d%s%s%s%d%d%s,&p1-num1,p1-name1,p1-major,p1-type,&p1-cr edit,&p1-period,p1-teacher);p1-people=0;insert(p1); break;case 2:printf( 請輸入您要?jiǎng)h除的課程編號(hào):n);scanf(%d,&num1);delc(num1); break;case 3:break;void putin(void) /從鍵盤錄入學(xué)生信息int i;struct student *p1,*p2;N2=0;p1=p2=(struct studen
10、t *)malloc(sizeof(struct student);printf( 學(xué)號(hào) 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)head2=p1;elsep2-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
11、;p2-next=NULL;void putin2() /從文件錄入學(xué)生信息int i=0;FILE * fp;char filepath20;struct student *p1,*p2;N2=0;printf( 請輸入您要讀取的路徑:);getchar();gets(filepath);if(fp=fopen(filepath,rt)=NULL)printf( 找不到 %s 文件 !n,filepath);exit(0);p1=p2=(struct student*)malloc(sizeof(struct student);fread(p1,sizeof(struct student),
12、1,fp);head2=NULL;while(!feof(fp)i=0;N2=N2+1;if(N2=1)head2=p1;elsep2-next=p1;p2=p1;p1=(struct student * )malloc(sizeof(struct student);fread(p1,sizeof(struct student),1,fp);p2-next=NULL;void input() /錄入學(xué)生信息函數(shù)int i;printf(ttt 錄入學(xué)生信息n);printf(n1. 從鍵盤錄入n);printf(2.從文件錄入n);printf(3.返回主菜單n);printf( 請輸入 1-
13、3:n);scanf(%d,&i);switch(i)case 1:putin(); break;case 2:putin2(); break;case 3:break;增加學(xué)生信息void inserts(struct student * incouse) /struct student *p0,*p1,*p2;p1=head2;p0=incouse;if(head2=NULL)head2=p0;p0-next=NULL;elsewhile(p0-num2p1-num2) & (p1-next!=NULL)p2=p1;p1=p1-next;if(p0-num2 num2)if(head2=p
14、1) head2=p0;else p2-next=p0;p0-next=p1;elsep1-next=p0;p0-next=NULL;N2=N2+1;void dels(int num2)/刪除學(xué)生信息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;elsep2-next=p1-next;printf( 已刪除
15、n);N2=N2-1;elseprintf( 沒有此學(xué)生編號(hào)n);end:;void managements() / 學(xué)生信息管理函數(shù)struct student * p1;int i,num2;printf(ttt 學(xué)生信息管理n);printf(1.添加學(xué)生信息n);printf(2.刪除學(xué)生信息n);printf(3. 返回主菜單n);printf( 請選擇 1-3:n);scanf(%d,&i);switch(i)case 1:p1=(struct student *)malloc(sizeof(struct student);p1-nelen=0;p1-nelenum0=0;prin
16、tf(numtnamen);scanf(%d%s,&p1-num2,p1-name2);inserts(p1);break;case 2:printf( 請輸入您要?jiǎng)h除的學(xué)生編號(hào):n);scanf(%d,&num2);dels(num2); break;case 3:break;void elect() /學(xué)生選課struct student * s;struct course * p;int a,i,b;printf( 請輸入您的學(xué)號(hào):n);scanf(%d,&a);s=head2;while(s-num2)!=a&s-next!=NULL) s=s-next;if(s-num2!=a)pr
17、intf( 您的信息不存在,請重新輸入:n);goto end;if(s-nelen)10)printf( 您的學(xué)分已滿);goto end;printf( 請輸入您要選修的課程編號(hào)n);scanf(%d,&b);for(i=0;(s-nelenumi)=0;i+);s-nelenumi=b;p=head1;while(p-num1)!=b)p=p-next;for(i=0;(s-nelenumi)!=0;i+);s-nelenumi=b;(p-people)+;(s-nelen)=(s-nelen)+(p-credit);(p-people)+;end:;void back() /學(xué)生退課s
18、truct student * p;struct course * p1;int b,i,j,a;printf( 請輸入您的學(xué)號(hào):n);scanf(%d,&a);p=head2;while(p-num2!=a&p!=NULL) p=p-next;if(p=NULL)printf( 您的信息不存在:n);elseprintf( 請輸入您要退選的課程:n);scanf(%d,&b);p1=head1;while(p1-num1!=b) p1=p1-next;for(i=0;p-nelenumi!=b;i+);for(j=i;p-nelenumj!=0;j+)p-nelenumj=p-nelenum
19、j+1;p-nelenum-j=0;(p-nelen)=(p-nelen)-(p1-credit);(p1-people)-;printf(succeed!n);void elective()/學(xué)生選課信息管理int i;printf(ttt 學(xué)生選課信息管理n);printf(1.選課n);printf(2.退課n);printf(3. 返回主菜單n);printf( 請輸入 1-3:n);scanf(%d,&i);switch(i)case 1:elect();break;case 2:back();break;case 3:break;void listc()/瀏覽課程信息struct
20、course * p;p=head1;printf( 課程編號(hào)課程名稱主修課程性質(zhì)學(xué)分課時(shí)教師 選課人數(shù) n);while(p!=NULL)printf(%6d%13s%13s%10s%7d%7d%12s%5dn,p-num1,p-name1,p-major ,p-type,p-credit,p-period,p-teacher,p-people);p=p-next; /瀏覽學(xué)生信息void lists()struct student * p;int a;p=head2;所選課程學(xué)分printf( 學(xué)生編號(hào)學(xué)生姓名所選課程編號(hào)n);while(p!=NULL)printf(%6d%13s,p-
21、num2,p-name2);printf(%6d,p-nelen);for(a=0;p-nelenuma!=0&anelenuma);printf(n);p=p-next;void intoc()/存儲(chǔ)課程信息FILE * fp;struct course * p;char filepath30;printf( 輸入路徑:);getchar();gets(filepath);if(fp=fopen(filepath,w)=NULL)無法儲(chǔ)存 !);exit(0);p=head1;while(p!=NULL)fprintf(fp,%d%s%s%s%d%d%s%dn,p-num1,p-name1,
22、p-major,p-type ,p-credit,p-period,p-teacher,p-people);p=p-next;fclose(fp);printf(已儲(chǔ)存入 s文件!n,filepath);void intos()/存儲(chǔ)學(xué)生信息FILE * fp;struct student * p;char filepath30;printf( 請輸入路徑:);getchar();gets(filepath);if(fp=fopen(filepath,wt)=NULL)printf(n 無法儲(chǔ)存!);exit(0);p=head2;while(p!=NULL)fwrite(p,sizeof(s
23、truct student),1,fp);p=p-next;fclose(fp);printf( 已儲(chǔ)存入%s 文件 !n,filepath);void into() /信息存儲(chǔ)函數(shù)int i;printf(ttt 信息存儲(chǔ)n);printf(1. 課程信息存儲(chǔ)n);printf(2. 學(xué)生信息存儲(chǔ)tn);printf(3. 返回主菜單n);printf( 請輸入 1-3n);scanf(%d,&i);switch(i)case(1):intoc();break;case(2):intos();break;case(3):break;void store()/int i;printf(tt 信
24、息存儲(chǔ)和瀏覽n);printf(1.課程信息瀏覽n);printf(2.學(xué)生信息瀏覽n);printf(3. 信息存儲(chǔ)n);printf(4. 返回主菜單n);printf( 請輸入 1-4:n);scanf(%d,&i);switch(i)case(1):listc();break;case(2):lists();break;case(3):into();break;信息存儲(chǔ)瀏覽函數(shù)case(4):break; void search1()/按學(xué)生編號(hào)查找學(xué)生信息int a,b;struct student * p;printf( 請輸入學(xué)生編號(hào));scanf(%d,&a);p=head2;
25、printf( 學(xué)號(hào)學(xué)生姓名所選課程編號(hào)所選課程學(xué)分n);while(p!=NULL)if(p-num2=a)printf(%6d%13s ,p-num2,p-name2);for(b=0;p-nelenumb!=0&bnelenumb);printf(%10dn,p-nelen);p=p-next;void search2()/按學(xué)生姓名查找學(xué)生信息int b;char name20;struct student * p;printf( 請輸入要查找的學(xué)生姓名:);scanf(%s,name);p=head2;printf( 學(xué)號(hào)學(xué)生姓名所選課程編號(hào)所選課程學(xué)分n);while(p!=NULL)if(strcmp(name,p-name2)=0)printf(%6d%13s ,p-num2,p-name2);for(b=0;p-nelenumb!=0&bnelenumb);printf(%10dn,p-nelen); p=p-next;void search()/學(xué)生信息查找主函數(shù)int i;printf(ttt 學(xué)生信息查找);printf(n1.按學(xué)號(hào)查找);printf(n2.按姓名查找);printf(n3.返回主菜單);printf(n 請輸入 1-3:);scanf(%d,&i);
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(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ǔ)空間,僅對用戶上傳內(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年度智能農(nóng)業(yè)作物損壞賠償與病蟲害防治服務(wù)協(xié)議
- 二零二五醫(yī)療事故賠償協(xié)議書撰寫要點(diǎn)解析
- 2025年度智能化住宅房屋租賃定金合同模板范文
- 二零二五年度知識(shí)產(chǎn)權(quán)戰(zhàn)略布局專利代理合同
- 二零二五年度主播才藝展示及經(jīng)紀(jì)管理協(xié)議
- 二零二五年度能源合同可撤銷條款與節(jié)能減排合同
- 二零二五年度全新辦公區(qū)轉(zhuǎn)租協(xié)議合同:商務(wù)辦公空間租賃權(quán)轉(zhuǎn)讓
- 二零二五年度合同管理制及流程圖編制與執(zhí)行標(biāo)準(zhǔn)合同
- 2025年度智能醫(yī)療設(shè)備研發(fā)團(tuán)隊(duì)技術(shù)人員勞動(dòng)合同
- 二零二五年度新材料專利共享許可協(xié)議
- 2025年高考語文備考訓(xùn)練之社會(huì)現(xiàn)象:“數(shù)字囤積癥”
- 2025包頭青山賓館有限公司面向社會(huì)公開招聘18人筆試參考題庫附帶答案詳解
- 《運(yùn)營管理 第7版》課件全套 馬風(fēng)才 第01-15章 運(yùn)營管理概論- 互聯(lián)網(wǎng)運(yùn)營
- 2025至2030年中國毛絨卡通玩具數(shù)據(jù)監(jiān)測研究報(bào)告
- 2025年度智能充電樁場地租賃合同范本3篇
- 2025年度典型火災(zāi)案例及消防安全知識(shí)專題培訓(xùn)
- 2024年蕪湖職業(yè)技術(shù)學(xué)院高職單招語文歷年參考題庫含答案解析
- 17J008擋土墻(重力式、衡重式、懸臂式)圖示圖集
- 2025年度國家鐵路局安全技術(shù)中心面向社會(huì)公開招聘工作人員5人高頻重點(diǎn)提升(共500題)附帶答案詳解
- 北師大版三年級下冊數(shù)學(xué)口算題練習(xí)1000道帶答案
- 技術(shù)推廣服務(wù)合同模板五篇
評論
0/150
提交評論