課程信息管理系統(tǒng)C語(yǔ)言程序_第1頁(yè)
課程信息管理系統(tǒng)C語(yǔ)言程序_第2頁(yè)
課程信息管理系統(tǒng)C語(yǔ)言程序_第3頁(yè)
課程信息管理系統(tǒng)C語(yǔ)言程序_第4頁(yè)
課程信息管理系統(tǒng)C語(yǔ)言程序_第5頁(yè)
已閱讀5頁(yè),還剩14頁(yè)未讀 繼續(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<stdio.h> #include<stdlib.h>#include<string.h> typedef struct char num15; char name20; char credit10; char clas20; char teacher20; student; student pe80; int menu_select() char c; do system("cls"); printf("+-+n"); printf("| |n"); printf("|

2、 歡迎使用課程信息管理系統(tǒng) |n"); printf("| |n"); printf("+-+n");printf("tt *課程信息管理系統(tǒng)* n"); printf("tt n"); printf("tt 1. 增加記錄 n"); printf("tt 2. 顯示記錄 n"); printf("tt 3. 查詢記錄 n"); printf("tt 4. 修改記錄 n"); printf("tt 5. 刪除記錄 n

3、"); printf("tt 6. 存儲(chǔ)記錄 n");printf("tt 0. 退出程序 n"); printf("tt n"); printf("tt請(qǐng)您選擇(0-6):"); c=getchar(); while(c<'0'|c>'6'); return(c-'0'); int Input(student per,int n) int i=0; char sign,x10; while(sign!='n'&&

4、sign!='N') printf("t課程編號(hào):"); scanf("t%s",pern+i.num); printf("t課程名稱:"); scanf("t%s",pern+); printf("t學(xué)分:"); scanf("t%s",pern+i.credit);printf("t選修課號(hào):");scanf("t%s",pern+i.clas);printf("t任課教師:");sc

5、anf("t%s",pern+i.teacher);gets(x); printf("nt是否繼續(xù)添加?(Y/N)"); scanf("t%c",&sign); i+; return(n+i); void Display(student per,int n) int i; printf("-n"); /*格式*/ printf("課程編號(hào) 課程名稱 學(xué)分 選修課號(hào) 任課教師 n"); printf("-n"); for(i=1;i<n+1;i+) printf(

6、"%-12s%-12s%-15s%-18s%sn",peri-1.num,,peri-1.credit,peri-1.clas,peri-1.teacher); if(i>1&&i%10=0) printf("t-n"); printf("t"); system("pause"); printf("t-n"); printf("-n");system("pause"); int Delete_a_record(s

7、tudent per,int n) /刪除學(xué)生記錄函數(shù) char s20; int i=0,j; printf("t請(qǐng)輸入想刪除記錄中的課程編號(hào):"); scanf("%s",s); while(strcmp(peri.num,s)!=0&&i<n) i+; if(i=n) printf("t系統(tǒng)中沒有此科目!n"); return(n); for(j=i;j<n-1;j+) strcpy(perj.num,perj+1.num); strcpy(,perj+1.name); strcpy

8、(perj.credit,perj+1.credit);strcpy(perj. clas,perj+1. clas);strcpy(perj. teacher,perj+1. teacher); printf("ttt已經(jīng)成功刪除!n"); return(n-1); void Query_a_record(student per,int n) /查詢學(xué)生記錄 int m;printf("tn請(qǐng)選擇查詢方式:n"); printf("t-n"); printf("t1-課 程 編 號(hào)n"); printf(&quo

9、t;t2-課 程 名 稱n"); printf("t3-返 回 n"); printf("t-n"); printf("請(qǐng)選擇:"); scanf("%d",&m); while(m!=1&&m!=2&&m!=3) printf("輸入錯(cuò)誤,請(qǐng)重新選擇:");scanf("%d",&m);if(m=1) / 按課程編號(hào)查詢char s20; int i=0; printf("t請(qǐng)輸入想查詢的課程編號(hào):&quo

10、t;); scanf("t%s",s); while(strcmp(peri.num,s)!=0&&i<n) i+; if(i=n) printf("t系統(tǒng)中沒有這個(gè)科目!n"); return; printf("t課程名稱: %sn",); printf("t學(xué)分: %sn",peri. credit); printf("t選修課號(hào): %sn",peri.clas); printf("t任課教師: %sn",peri.teacher)

11、; ;if(m=2) /按課程名稱查詢char s20; int i=0; printf("t請(qǐng)輸入想查詢的課程名稱:"); scanf("t%s",s); while(strcmp(,s)!=0&&i<n) i+; if(i=n) printf("t系統(tǒng)中沒有該科目!n"); return; printf("t課程編號(hào) %sn",peri.num); printf("t學(xué)分: %sn",peri.credit); printf("t選修課號(hào):

12、%sn",peri.clas); printf("t任課教師: %sn",peri.teacher); ;void Change(student per,int n) /修改課程記錄char s20; int i=0; printf("t請(qǐng)輸入想修改的課程信息管理系統(tǒng)中的課程編號(hào):"); scanf("%s",s); while(strcmp(peri.num,s)!=0&&i<n) i+; if(i=n) printf("t系統(tǒng)中沒有該科目!n"); return; printf(

13、"t課程編號(hào):"); scanf("t%s",peri.num); printf("t課程名稱:"); scanf("t%s",); printf("t學(xué)分:"); scanf("t%s",peri.credit);printf("t選修課號(hào):");scanf("t%s",peri.clas);printf("t任課教師:");scanf("t%s",peri.teacher);

14、printf("t修改成功!");void WritetoText(student per,int n) int i=0; FILE *fp; /定義文件指針 char filenum20; /定義文件名 printf("t保存到文件n"); /輸入文件名 printf("t請(qǐng)輸入所保存的文件名:"); scanf("t%s",filenum); if(fp=fopen(filenum,"w")=NULL) printf("t無法打開文件n"); system("p

15、ause"); return; fprintf(fp,"* 課程信息管理系統(tǒng)*n");fprintf(fp," 課程編號(hào) 課程名稱 學(xué)分 選修課號(hào) 任課教師 n");fprintf(fp,"-n");while(i<=n) fprintf(fp,"%-10s%-10s%-15s%-18s%sn",peri-1.num,,peri-1.credit,peri-1.clas,peri-1.teacher); i+; fprintf(fp,"-n");fprint

16、f(fp,"*共有%d條記錄*n",n); fclose(fp); /*關(guān)閉文件*/ printf("成功保存!n"); int main() int n=0; for(;) switch(menu_select() case 1: printf("nt請(qǐng)?jiān)黾佑涗浀较到y(tǒng)n");n=Input(pe,n); break; case 2: printf("nttt 課程信息管理系統(tǒng)記錄表n"); Display(pe,n); break;case 5: printf("nt從系統(tǒng)中刪除記錄n");

17、n=Delete_a_record(pe,n); printf("t"); system("pause"); break; case 3: printf("nt在系統(tǒng)中查找記錄n"); Query_a_record(pe,n); printf("t"); system("pause"); break;case 4: printf("nt修改系統(tǒng)中的記錄n"); Change(pe,n); printf("t"); system("pause&qu

18、ot;); break; case 6: printf("nt保存功能n"); WritetoText(pe,n); printf("t"); system("pause"); break; case 0: printf("ntt謝謝您的使用,歡迎下次再來!再見!n"); printf("ntt"); system("pause"); exit(0); return 0;#include<stdio.h>#include<string.h>struct

19、 linkchar cno10,cname10,cforecourse10,cunitno10,cunitname10;int ia;struct link *next;struct link *head;int menu()int ii;printf("please choose a number:n");printf("*:n");printf("1: create :n");printf("2: search :n");printf("3: delete :n");printf("

20、;4: view :n");printf("5: quit :n");printf("*:n");printf("n");printf("n");printf("n");printf("n");scanf("%d",&ii); return ii;struct link create()int icount,ij=1;struct link *p,*new;while(1)if(icount) printf("輸入頭結(jié)點(diǎn)&quo

21、t;);new=(struct link *)malloc(sizeof(struct link); printf("input the course no:n"); scanf("%s",new->cno); printf("input the course :n"); scanf("%s",new->cname); printf("input the forecourse :n"); scanf("%s",new->cforecourse); print

22、f("input the course grade:n"); scanf("%d",&new->ia); printf("input the unit no. grade:n"); scanf("%s",new->cunitno); printf("input the unit name:n"); scanf("%s",new->cunitname); new->next=NULL; if(icount) head=new; p=new; pr

23、intf("the fist add success:n"); getchar(); getchar(); icount=0; else p->next=new; printf("n"); p=p->next; printf("add success:n"); printf("n"); getchar(); printf("input 0 to end input:n");scanf("%d",&ij); if(ij=0)break;struct link

24、 search()struct link *p;char ckeyname10;p=head;printf("please input the name you want to view:n");scanf("%s",ckeyname);while(strcmp(ckeyname,p->cname)!=0&&p->next!=NULL)p=p->next;if(p->next=NULL)printf("no this position:n");elseprintf("found it:

25、n");printf("%s,%s,%s,%d,%s,%s",p->cno,p->cname,p->cforecourse,p->ia,p->cunitno,p->cunitname);struct link delete()struct link *p,*q,*r;char ckeyname10;r=head;p=r->next;q=p->next;printf("please input the name you want to del:n");scanf("%s",cke

26、yname);while(strcmp(ckeyname,p->cname)!=0&&r->next!=NULL)r=r->next;p=p->next;q=q->next;if(r->next=NULL)printf("no this position:n");elseprintf("found it:n");printf("%s,%s,%s,%d,%s,%s",p->cno,p->cname,p->cforecourse,p->ia,p->cunit

27、no,p->cunitname);r->next=p->next;printf("delete success:n");getchar(); getchar();void output()struct link *p,*q;p=head;p=p->next;q=head;if(q->next=NULL) printf("no record:n");elsewhile(p->next)printf("%s,%s,%s,%d,%s,%s",p->cno,p->cname,p->cfor

28、ecourse,p->ia,p->cunitno,p->cunitname);printf("n");p=p->next;printf("%s,%s,%s,%d,%s,%s",p->cno,p->cname,p->cforecourse,p->ia,p->cunitno,p->cunitname);void quit()exit(0);void main()int ia=1;head=NULL;while(ia!=5)ia=menu();switch(ia)case 1:create();bre

29、ak;case 2:search();break; case 3:delete();break; case 4:output();break;case 5:quit();break;default:printf("input wrong:n");#include<stdio.h> #include<stdlib.h>#include<string.h> typedef struct char num15; char name20; char credit10; char clas20; char teacher20; student; s

30、tudent pe80; int menu_select() char c; do system("cls"); printf("n"); printf("n"); printf(" 歡迎使用課程信息管理系統(tǒng) n"); printf("n"); printf("n");printf(" 課程信息管理系統(tǒng) n"); printf("n"); printf(" 1. 增加記錄 n"); printf(" 2.

31、顯示記錄 n"); printf(" 3. 查詢記錄 n"); printf(" 4. 修改記錄 n"); printf(" 5. 刪除記錄 n"); printf(" 6. 存儲(chǔ)記錄 n");printf(" 0. 退出程序 n"); printf("n"); printf("tt請(qǐng)您選擇(0-6):"); c=getchar(); while(c<'0'|c>'6'); return(c-'

32、0'); int Input(student per,int n) int i=0; char sign,x10; while(sign!='n'&&sign!='N') printf("t課程編號(hào):"); scanf("t%s",pern+i.num); printf("t課程名稱:"); scanf("t%s",pern+); printf("t學(xué)分:"); scanf("t%s",pern+i.cred

33、it);printf("t選修課號(hào):");scanf("t%s",pern+i.clas);printf("t任課教師:");scanf("t%s",pern+i.teacher);gets(x); printf("nt是否繼續(xù)添加?(Y/N)"); scanf("t%c",&sign); i+; return(n+i); void Display(student per,int n) int i; printf("-n"); /*格式*/ pri

34、ntf("課程編號(hào) 課程名稱 學(xué)分 選修課號(hào) 任課教師 n"); printf("-n"); for(i=1;i<n+1;i+) printf("%-12s%-12s%-15s%-18s%sn",peri-1.num,,peri-1.credit,peri-1.clas,peri-1.teacher); if(i>1&&i%10=0) printf("t-n"); printf("t"); system("pause"); p

35、rintf("t-n"); printf("-n");system("pause"); int Delete_a_record(student per,int n) /刪除學(xué)生記錄函數(shù) char s20; int i=0,j; printf("t請(qǐng)輸入想刪除記錄中的課程編號(hào):"); scanf("%s",s); while(strcmp(peri.num,s)!=0&&i<n) i+; if(i=n) printf("t系統(tǒng)中沒有此科目!n"); ret

36、urn(n); for(j=i;j<n-1;j+) strcpy(perj.num,perj+1.num); strcpy(,perj+1.name); strcpy(perj.credit,perj+1.credit);strcpy(perj. clas,perj+1. clas);strcpy(perj. teacher,perj+1. teacher); printf("ttt已經(jīng)成功刪除!n"); return(n-1); void Query_a_record(student per,int n) /查詢學(xué)生記錄 int m;printf(

37、"tn請(qǐng)選擇查詢方式:n"); printf("n"); printf("1-課程編號(hào)n"); printf("2-課程名稱n"); printf("3-返 回n"); printf("n"); printf("請(qǐng)選擇:"); scanf("%d",&m); while(m!=1&&m!=2&&m!=3) printf("輸入錯(cuò)誤,請(qǐng)重新選擇:");scanf("%d

38、",&m);if(m=1) / 按課程編號(hào)查詢char s20; int i=0; printf("t請(qǐng)輸入想查詢的課程編號(hào):"); scanf("t%s",s); while(strcmp(peri.num,s)!=0&&i<n) i+; if(i=n) printf("t系統(tǒng)中沒有這個(gè)科目!n"); return; printf("t課程名稱: %sn",); printf("t學(xué)分: %sn",peri. credit); prin

39、tf("t選修課號(hào): %sn",peri.clas); printf("t任課教師: %sn",peri.teacher); ;if(m=2) /按課程名稱查詢char s20; int i=0; printf("t請(qǐng)輸入想查詢的課程名稱:"); scanf("t%s",s); while(strcmp(,s)!=0&&i<n) i+; if(i=n) printf("t系統(tǒng)中沒有該科目!n"); return; printf("t課程編號(hào) %s

40、n",peri.num); printf("t學(xué)分: %sn",peri.credit); printf("t選修課號(hào): %sn",peri.clas); printf("t任課教師: %sn",peri.teacher); ;void Change(student per,int n) /修改課程記錄char s20; int i=0; printf("t請(qǐng)輸入想修改的課程信息管理系統(tǒng)中的課程編號(hào):"); scanf("%s",s); while(strcmp(peri.num,s)

41、!=0&&i<n) i+; if(i=n) printf("t系統(tǒng)中沒有該科目!n"); return; printf("t課程編號(hào):"); scanf("t%s",peri.num); printf("t課程名稱:"); scanf("t%s",); printf("t學(xué)分:"); scanf("t%s",peri.credit);printf("t選修課號(hào):");scanf("t%s",peri.clas);printf("t任課教師:");scanf("t%s",peri.teacher);printf("t修改成功!");void WritetoText(student per,in

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝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ù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 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ì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論