


版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、#include<stdio.h>#include<stdlib.h>#include<string.h>intN1,N2;structstudentintnum2;charname220;intnelenum50;/intnelen;/structstudent*next;structcourseintnuml;/課程編號charname120;charmajor20;chartype20;intcredit;intperiod;charteacher20;intpeople;/structcourse*next;/;structcourse*headl;
2、structstudent*head2;voidzhang()/structcourse*p1,*p2;所選課程編號所選課程學分和選此門課程的人數(shù)結構體指針從鍵盤錄入課程信息N1=0;p1=p2=(structcourse*)malloc(sizeof(structcourse);printf(-課程編號t課程名稱t主修t課程性質t學分t課時t教師n");scanf("%d%s%s%s%d%d%s",&p1->num1,p1->name1,p1->major,p1->type,&p1->credit,&p1-&
3、gt;period,p1->teacher);p1->people=0;head1=NULL;while(p1->num1!=0)N1=N1+1;if(N1=1)head1=p1;elsep2->next=p1;p2=p1;p1=(structcourse*)malloc(sizeof(structcourse);scanf("%d%s%s%s%d%d%s",&p1->num1,p1->name1,p1->major,p1->type,&p1->credit,&p1->period,p1-&
4、gt;teacher);p1->people=0;p2->next=NULL;voidzhang1()/從文件錄入課程信息FILE*fp;charfilepath20;structcourse*p1,*p2;N1=0;printf(-請輸入您要讀取的路徑:");getchar();gets(filepath);if(fp=fopen(filepath,"r")=NULL)(printf("找不到%s文件!n",filepath);exit(0);p1=p2=(structcourse*)malloc(sizeof(structcou
5、rse);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)head1=p1;elsep2->next=p1;p2=p1;p1=(structcourse*)malloc(sizeof(structcourse);fscanf(fp,"
6、%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;voidload()/錄入課程信息函數(shù)(inti;printf("ttt錄入課程信息n");printf("n1.從鍵盤錄入");printf("n2.從文件錄入");printf("n3.返回
7、主菜單n");printf("請選擇1-3:");scanf(”d”,&i);switch(i)(case1:zhang();break;case2:zhang1();break;case3:break;voidinsert(structcourse*incourse)/增加課程信息(structcourse*p0,*p1,*p2;p1=head1;p0=incourse;if(head1=NULL)(head1=p0;p0->next=NULL;else(while(p0->num1>p1->num1)&&(p1-
8、>next!=NULL)(p2=p1;p1=p1->next;if(p0->num1<=p1->num1)(if(head1=p1)head1=p0;elsep2->next=p0;p0->next=p1;else(p1->next=p0;p0->next=NULL;N1=N1+1;voiddelc(intnum1)/刪除課程信息(structcourse*p1,*p2;if(head1=NULL)(printf("n無法刪除!n");gotoend;p1=head1;while(num1!=p1->num1&am
9、p;&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()/課程信息管理函數(shù)(structcourse*p1;inti,num1;printf("ttt課程信息管理n");printf("1.添加課程n&
10、quot;);printf("2.刪除課程n");printf("3.返回n");printf("請輸入1-3:n");scanf("%d",&i);switch(i)(case1:p1=(structcourse*)malloc(sizeof(structcourse);printf(-課程編號t課程名稱t主修t課程性質t學分t課時t教師n");scanf("%d%s%s%s%d%d%s",&p1->num1,p1->name1,p1->major,
11、p1->type,&p1->credit,&p1->period,p1->teacher);p1->people=0;insert(p1);break;case2:printf("請輸入您要刪除的課程編號:n");scanf("%d",&num1);delc(num1);break;case3:break;voidputin(void)/從鍵盤錄入學生信息(inti;structstudent*p1,*p2;N2=0;p1=p2=(structstudent*)malloc(sizeof(struct
12、student);printf("學號t姓名n");scanf("%d%s”,&p1->num2,p1->name2);p1->nelen=0;for(i=0;i<20;i+)p1->nelenumi=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->nu
13、m2,p1->name2);p1->nelen=0;for(i=0;i<20;i+)p1->nelenumi=0;p2->next=NULL;voidputin2()/從文件錄入學生信息(inti=0;FILE*fp;charfilepath20;structstudent*p1,*p2;N2=0;printf(-請輸入您要讀取的路徑:,getchar();gets(filepath);if(fp=fopen(filepath,"rt")=NULL)printf("找不到%s文件!n",filepath);exit(0);p
14、1=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;voidinput()/錄入學生信息函數(shù)inti;printf
15、("ttt錄入學生信息n");printf("n1.從鍵盤錄入n");printf("2.從文件錄入n");printf("3.返回主菜單n");printf("請輸入1-3:n");scanf(”d”,&i);switch(i)case1:putin();break;case2:putin2();break;case3:break;voidinserts(structstudent*incouse)/增加學生信息structstudent*p0,*p1,*p2;p1=head2;p0=
16、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<=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)/刪除學生信息(structstu
17、dent*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:;voidmanagem
18、ents。/學生信息管理函數(shù)structstudent*p1;inti,num2;printf("ttt學生信息管理n");printf("1.添加學生信息n");printf("2.刪除學生信息n");printf("3.返回主菜單n");printf("請選擇1-3:n");scanf("%d",&i);switch(i)case1:p1=(structstudent*)malloc(sizeof(structstudent);p1->nelen=0;p1-
19、>nelenum0=0;printf("numtnamen");scanf("%d%s",&p1->num2,p1->name2);inserts(p1);break;case2:printf(-請輸入您要刪除的學生編號:n");scanf("%d",&num2);dels(num2);break;case3:break;voidelect()/學生選課(structstudent*s;structcourse*p;inta,i,b;printf("請輸入您的學號:n")
20、;scanf("%d",&a);s=head2;while(s->num2)!=a&&s->next!=NULL)s=s->next;if(s->num2!=a)(printf(-您的信息不存在,請重新輸入:n");gotoend;if(s->nelen)>10)(printf("您的學分已滿");gotoend;printf("請輸入您要選修的課程編號n");scanf("%d",&b);for(i=0;(s->nelenumi)
21、=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:;voidback()/學生退課(structstudent*p;structcourse*p1;intb,i,j,a;printf("請輸入您的學號:n");scanf("%d&q
22、uot;,&a);p=head2;while(p->num2!=a&&p!=NULL)p=p->next;if(p=NULL)printf(-您的信息不存在:n");else(printf("請輸入您要退選的課程: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->ne
23、lenumj+1;p->nelenum-j=0;(p->nelen)=(p->nelen)-(p1->credit);(p1->people)-;printf("succeed!n");voidelective()/學生選課信息管理inti;printf("ttt學生選課信息管理n");printf("1.選課n");printf("2.退課n");printf("3.返回主菜單n");printf("請輸入1-3:n");scanf(”d”,&
24、amp;i);switch(i)(case1:elect();break;case2:back();break;case3:break;voidlistc()/瀏覽課程信息(structcourse*p;p=head1;printf(-課程編號課程名稱主修課程性質學分課時教師選課人數(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
25、,p->people);p=p->next;voidlists()/瀏覽學生信息(structstudent*p;inta;p=head2;printf(-學生編號學生姓名所選課程編號所選課程學分n");while(p!=NULL)(printf("%6d%13s",p->num2,p->name2);printf("%6d",p->nelen);for(a=0;p->nelenuma!=0&&a<14;a+)printf("%d",p->nelenuma);p
26、rintf("n");p=p->next;voidintoc()/存儲課程信息(FILE*fp;structcourse*p;charfilepath30;printf(-輸入路徑:");getchar();gets(filepath);if(fp=fopen(filepath,"w")=NULL)(無法儲存!");exit(0);p=head1;while(p!=NULL)fprintf(fp,"%d%s%s%s%d%d%s%dn",p->num1,p->name1,p->major,p-
27、>type,p->credit,p->period,p->teacher,p->people);p=p->next;fclose(fp);printf("已儲存入s文件!n",filepath);voidintos()/存儲學生信息(FILE*fp;structstudent*p;charfilepath30;printf(-請輸入路徑:");getchar();gets(filepath);if(fp=fopen(filepath,"wt")=NULL)(printf("n無法儲存!")
28、;exit(0);p=head2;while(p!=NULL)(fwrite(p,sizeof(structstudent),1,fp);p=p->next;fclose(fp);printf("已儲存入%s文件!n",filepath);voidinto()/(信息存儲函數(shù)inti;printf("ttt信息存儲n");printf("1.課程信息存儲n");printf("2.學生信息存儲tn");printf("3.返回主菜單n");printf("請輸入1-3n"
29、;);scanf("%d",&i);switch(i)case(1):intoc();break;case(2):intos();break;case(3):break;信息存儲瀏覽函數(shù)voidstore()/(inti;printf(-tt信息存儲和瀏覽n");printf("1.課程信息瀏覽n");printf("2.學生信息瀏覽n");printf("3.信息存儲n");printf("4.返回主菜單n");printf("請輸入1-4:n");sca
30、nf("%d",&i);switch(i)(case(1):listc();break;case(2):lists();break;case(3):into();break;case(4):break;voidsearch1()/按學生編號查找學生信息(inta,b;structstudent*p;printf(-請輸入學生編號");scanf("%d",&a);p=head2;printf(-學號學生姓名所選課程編號所選課程學分n");while(p!=NULL)(if(p->num2=a)(printf(&q
31、uot;%6d%13s",p->num2,p->name2);for(b=0;p->nelenumb!=0&&b<14;b+)printf("%d",p->nelenumb);printf("%10dn",p->nelen);p=p->next;voidsearch2()/按學生姓名查找學生信息(intb;charname20;structstudent*p;printf(-請輸入要查找的學生姓名:");scanf("%s",name);p=head2;pr
32、intf(-學號學生姓名所選課程編號所選課程學分n");while(p!=NULL)(if(strcmp(name,p->name2)=0)(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=p->next;voidsearch()/學生信息查找主函數(shù)(inti;printf(-ttt學生信息查找");printf("n1.按學號查找");printf("n2.按姓名查找");printf("n3.返回主菜單");printf("n請輸入1-3:");scanf("%d",&i);switch(i)(case1:search1();break;case2:search2();break;case3:break;voidmain()/主函數(shù)
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 高粱根教學課件
- 趙志祥的一分鐘教學課件
- 紋身教學課件
- 美術教學課件大綱
- 閱讀教學指導課件
- 順采茶教學課件
- 教學課件母版設計
- 散步教學說課課件
- 幼兒教學掛圖課件
- 浙江寧波寧??h2022自主招生考試數(shù)學試題真題(含答案詳解)
- 2023-2023學年貴州省黔西南州八年級(下)期末數(shù)學試卷(附答案詳解)
- 普利制藥SAP項目研發(fā)產品及工藝驗證產品費用歸集V11
- LY/T 1575-2023汽車車廂底板用竹膠合板
- 人情往來(禮金)賬目表
- 林下種植中藥材的可行性方案
- 東北大學分析化學期末試卷
- 老年健康照護課件
- 稅收政策解讀與應用
- 辦公室清潔值日表范本
- 鋼廠燒結機安裝施工組織設計
- 【醫(yī)學課件】糞便檢驗
評論
0/150
提交評論