




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、#include<stdio.h>#include<stdlib.h>#include<string.h>int N1,N2;struct studentint num2; char name220; int nelenum50; /所選課程編號(hào) int nelen; /所選課程學(xué)分和 struct student * next;struct courseint num1; /課程編號(hào)char name120; char major20;char type20;int credit;int period;char teacher20;int people;
2、/選此門(mén)課程的人數(shù)struct course *next; /結(jié)構(gòu)體指針;struct course * head1;struct student * head2;void zhang() /從鍵盤(pán)錄入課程信息struct course *p1,*p2; N1=0; p1=p2=(struct course *)malloc(sizeof(struct course); printf("課程編號(hào)t課程名稱(chēng)t主修t課程性質(zhì)t學(xué)分t課時(shí)t教師n"); scanf("%d%s%s%s%d%d%s",&p1->num1,p1->name1,p
3、1->major,p1->type,&p1->credit,&p1->period,p1->teacher); p1->people=0; head1=NULL; while(p1->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
4、->major,p1->type,&p1->credit,&p1->period,p1->teacher); p1->people=0; p2->next=NULL;void zhang1() /從文件錄入課程信息FILE * fp; char filepath20; struct course *p1,*p2; N1=0; printf("請(qǐng)輸入您要讀取的路徑:"); getchar(); gets(filepath); if(fp=fopen(filepath,"r")=NULL)printf
5、("找不到 %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=1)hea
6、d1=p1; else p2->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;pr
7、intf("ttt錄入課程信息n");printf("n1.從鍵盤(pán)錄入");printf("n2.從文件錄入");printf("n3.返回主菜單n");printf("請(qǐng)選擇1-3:");scanf("%d",&i);switch(i)case 1: zhang(); break; case 2:zhang1();break; case 3:break; void insert(struct course *incourse) /增加課程信息struct cours
8、e *p0,*p1,*p2; p1=head1; p0=incourse; if(head1=NULL)head1=p0; p0->next=NULL; elsewhile(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
9、=N1+1;void delc(int num1) /刪除課程信息struct course *p1,*p2; if(head1=NULL)printf("n無(wú)法刪除!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("已刪除n"
10、;); N1=N1-1; else printf("沒(méi)有此課程n"); end:;void managementc() /課程信息管理函數(shù)struct course * p1; int i,num1; printf("ttt課程信息管理n"); printf("1.添加課程n"); printf("2.刪除課程n"); printf("3.返回n"); printf("請(qǐng)輸入1-3:n"); scanf("%d",&i); switch(i) ca
11、se 1:p1=(struct course *)malloc(sizeof(struct course);printf("課程編號(hào)t課程名稱(chēng)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->credit,&p1->period,p1->teacher);p1->people=0;insert(p1); break;case 2:printf("請(qǐng)
12、輸入您要?jiǎng)h除的課程編號(hào):n");scanf("%d",&num1);delc(num1); break;case 3:break;void putin(void) /從鍵盤(pán)錄入學(xué)生信息 int i;struct student *p1,*p2;N2=0;p1=p2=(struct student *)malloc(sizeof(struct student);printf("學(xué)號(hào)t姓名n");scanf("%d%s",&p1->num2,p1->name2);p1->nelen=0;for(
13、i=0;i<20;i+) p1->nelenumi=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;i<20;i+) p1->nelenumi=0;p2->next=NULL;void pu
14、tin2() /從文件錄入學(xué)生信息int i=0;FILE * fp;char filepath20;struct student *p1,*p2;N2=0;printf("請(qǐng)輸入您要讀取的路徑:");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(stru
15、ct 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);fread(p1,sizeof(struct student),1,fp);p2->next=NULL;void input() /錄入學(xué)生信息函數(shù) int i;printf("ttt錄入學(xué)生信息n");printf("n1.從鍵盤(pán)錄入n");prin
16、tf("2.從文件錄入n");printf("3.返回主菜單n");printf("請(qǐng)輸入1-3:n");scanf("%d",&i);switch(i)case 1:putin(); break;case 2:putin2(); break;case 3:break;void inserts(struct student * incouse) /增加學(xué)生信息struct student *p0,*p1,*p2;p1=head2;p0=incouse;if(head2=NULL)head2=p0;p0-&g
17、t;next=NULL;elsewhile(p0->num2>p1->num2) && (p1->next!=NULL)p2=p1;p1=p1->next;if(p0->num2 <= p1->num2)if(head2=p1) 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)p
18、rintf("n無(wú)法刪除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("沒(méi)有此學(xué)生編號(hào)n");end:;void managements() /學(xué)生信息管理函數(shù)st
19、ruct student * p1;int i,num2;printf("ttt學(xué)生信息管理n");printf("1.添加學(xué)生信息n");printf("2.刪除學(xué)生信息n");printf("3.返回主菜單n");printf("請(qǐng)選擇1-3:n");scanf("%d",&i);switch(i)case 1:p1=(struct student *)malloc(sizeof(struct student);p1->nelen=0;p1->nele
20、num0=0;printf("numtnamen");scanf("%d%s",&p1->num2,p1->name2);inserts(p1);break;case 2:printf("請(qǐng)輸入您要?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("請(qǐng)輸入您的學(xué)號(hào):
21、n");scanf("%d",&a);s=head2;while(s->num2)!=a&&s->next!=NULL) s=s->next;if(s->num2!=a)printf("您的信息不存在,請(qǐng)重新輸入:n");goto end;if(s->nelen)>10)printf("您的學(xué)分已滿");goto end;printf("請(qǐng)輸入您要選修的課程編號(hào)n");scanf("%d",&b);for(i=0;(s
22、->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é)生退課struct student * p;struct course * p1;int b,i,j,a;printf("請(qǐng)輸入您的學(xué)號(hào):n&
23、quot;);scanf("%d",&a);p=head2;while(p->num2!=a&&p!=NULL) p=p->next;if(p=NULL)printf("您的信息不存在:n");elseprintf("請(qǐng)輸入您要退選的課程: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!
24、=0;j+)p->nelenumj=p->nelenumj+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(&
25、quot;請(qǐng)輸入1-3:n");scanf("%d",&i);switch(i)case 1:elect();break;case 2:back();break;case 3:break;void listc() /瀏覽課程信息struct course * p;p=head1;printf("課程編號(hào) 課程名稱(chēng) 主修 課程性質(zhì) 學(xué)分 課時(shí) 教師 選課人數(shù)n");while(p!=NULL)printf("%6d%13s%13s%10s%7d%7d%12s%5dn",p->num1,p->name1,p-
26、>major,p->type,p->credit,p->period,p->teacher,p->people);p=p->next;void lists() /瀏覽學(xué)生信息struct student * p;int a;p=head2;printf("學(xué)生編號(hào) 學(xué)生姓名 所選課程編號(hào) 所選課程學(xué)分n");while(p!=NULL)printf("%6d%13s",p->num2,p->name2);printf("%6d",p->nelen);for(a=0;p->
27、;nelenuma!=0&&a<14;a+)printf("%d",p->nelenuma);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)printf("無(wú)法儲(chǔ)存!");exit(0);p=he
28、ad1;while(p!=NULL)fprintf(fp,"%d%s%s%s%d%d%s%dn",p->num1,p->name1,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("
29、;請(qǐng)輸入路徑:");getchar();gets(filepath);if(fp=fopen(filepath,"wt")=NULL)printf("n 無(wú)法儲(chǔ)存!");exit(0);p=head2;while(p!=NULL)fwrite(p,sizeof(struct student),1,fp);p=p->next;fclose(fp);printf("已儲(chǔ)存入 %s文件!n",filepath);void into() /信息存儲(chǔ)函數(shù)int i;printf("ttt信息存儲(chǔ)n");pri
30、ntf("1.課程信息存儲(chǔ)n");printf("2.學(xué)生信息存儲(chǔ)tn");printf("3.返回主菜單n");printf("請(qǐng)輸入1-3n");scanf("%d",&i);switch(i)case(1):intoc();break;case(2):intos();break;case(3):break;void store() /信息存儲(chǔ)瀏覽函數(shù)int i;printf("tt信息存儲(chǔ)和瀏覽n");printf("1.課程信息瀏覽n");
31、printf("2.學(xué)生信息瀏覽n");printf("3.信息存儲(chǔ)n");printf("4.返回主菜單n");printf("請(qǐng)輸入1-4:n");scanf("%d",&i);switch(i)case(1):listc();break;case(2):lists();break;case(3):into();break;case(4):break;void search1() /按學(xué)生編號(hào)查找學(xué)生信息int a,b;struct student * p;printf("
32、請(qǐng)輸入學(xué)生編號(hào)");scanf("%d",&a);p=head2;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&&b<14;b+)printf("%d",p->nelenumb);printf("%10dn",p->nelen);p
33、=p->next;void search2() /按學(xué)生姓名查找學(xué)生信息int b;char name20;struct student * p;printf("請(qǐng)輸入要查找的學(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->nel
34、enumb!=0&&b<14;b+)printf("%d",p->nelenumb);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請(qǐng)輸入1-3:");scanf("%d",&i);switch(i)case 1:search1();break;case 2:search2();break;case 3:break;void main()
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年耐高溫濾料項(xiàng)目提案報(bào)告模板
- 2025年地區(qū)事業(yè)單位教師招聘考試數(shù)學(xué)學(xué)科專(zhuān)業(yè)知識(shí)試卷(數(shù)學(xué)分析)
- 2025年茶藝師(初級(jí))職業(yè)技能鑒定理論考試試卷(茶葉市場(chǎng)分析)
- 歷史專(zhuān)業(yè)古代戰(zhàn)爭(zhēng)史研究練習(xí)題
- 2025年電子商務(wù)師(初級(jí))職業(yè)技能鑒定試卷:電子商務(wù)數(shù)據(jù)分析報(bào)告撰寫(xiě)
- 2025年消防工程師消防設(shè)施設(shè)備選型與消防安全設(shè)施布置試題
- 2025年聲樂(lè)演唱教師資質(zhì)認(rèn)證模擬試題
- 2025年文化旅游演藝項(xiàng)目策劃運(yùn)營(yíng):文化旅游演藝項(xiàng)目創(chuàng)新策劃與市場(chǎng)拓展研究報(bào)告
- 汽車(chē)行業(yè)供應(yīng)鏈韌性?xún)?yōu)化與風(fēng)險(xiǎn)管理創(chuàng)新路徑報(bào)告
- 深度挖掘2025年K2教育人工智能個(gè)性化學(xué)習(xí)系統(tǒng)應(yīng)用效果與挑戰(zhàn)
- 高低壓變配電工程方案投標(biāo)文件(技術(shù)方案)
- 水泥檢測(cè)試題及答案
- 浙江省人教版小學(xué)一年級(jí)語(yǔ)文單元試卷
- 淋巴水腫專(zhuān)科護(hù)士培訓(xùn)匯報(bào)
- 2025年ASQ質(zhì)量經(jīng)理(CMQ.OE)認(rèn)證考試練習(xí)題庫(kù)(350題)
- 泰享懂你 康養(yǎng)友伴-2024年新康養(yǎng)需求洞察白皮書(shū)-華泰人壽
- 2025五級(jí)應(yīng)急救援員職業(yè)技能精練考試題庫(kù)及答案(濃縮400題)
- 城軌列控基礎(chǔ)設(shè)備列車(chē)測(cè)速裝置課件
- 村衛(wèi)生室年度校驗(yàn)工作總結(jié)
- 商務(wù)司機(jī)服務(wù)規(guī)范
- 2025年新思想概論考試題及答案
評(píng)論
0/150
提交評(píng)論