


版權(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> typedef structchar 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("|歡迎使用課程信息管理系統(tǒng) |n&
2、quot;)printf("|n")printf("+-+n");printf("tt* 課程信息管理系統(tǒng)* n");printf("tt11n");printf("tt1 1.增加記錄1n");printf("tt1 2.顯示記錄1n");printf("tt1 3.查詢記錄1n");printf("tt1 4.修改記錄1n");printf("tt1 5.刪除記錄1n");printf("tt1 6.存
3、儲(chǔ)記錄1n");printf("tt1 0.退出程序1n");printf("tt11n");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'&&sign!='N') printf("t 課
4、程編號(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 任課教師 :"); scanf("t%s",pe
5、rn+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("%-12s%-12s%-15s%-18s%sn
6、",peri-1.num,,peri-1.credit,peri-1.cla s,peri-1.teacher);if(i>1&&i%10=0)printf("tn");printf("t");system("pause");printf("tn");printf("n");system("pause");int Delete_a_record(student per,int n) / 刪除學(xué)生記錄函數(shù)char s20;i
7、nt 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(perj.credit,perj+1.credit);strcpy(perj. cla
8、s,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");prin tf("t1-i n");prin tf("t1- 課 程編 號(hào) |n");prin tf("t2- 課 程名稱|n");prin tf("t3
9、- 返回 | n");prin tf("t1- -1 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) :"); scanf("t%s",s
10、);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);if(m=2)char s20;/按課程名稱查詢
11、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) : %sn",peri.clas); prin
12、tf("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(&quo
13、t;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.
14、teacher);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 無(wú)法打開文件 n"); system("pause&quo
15、t;);return;"*課程信息管理系統(tǒng)*n");*fprintf(fp," 課程編號(hào) 課程名稱 學(xué)分選修課號(hào)任課教師 n");n");fprintf(fp,"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,"fprintf(fp,H*n",n);fclose(fp);printf(&
16、quot; 成功保存 !n");n");共 有 %d 條 記 錄/* 關(guā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;課程信息管理系統(tǒng)記錄表 n");case 2: printf("nttt Display(pe,n); break;case 5:printf("nt 從系統(tǒng)中刪除記錄 n"); n=Delete_a_record(pe,n);prin
17、tf("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");break;case 6:printf("nt 保存
18、功能 n");WritetoText(pe,n);printf("t");system("pause");break;case 0:! 再見 !n");printf("ntt 謝謝您的使用,歡迎下次再來(lái) printf("ntt");system("pause");exit(0);return 0;#include<stdio.h> #include<string.h>struct link char cno10,cname10,cforecourse10,cun
19、itno10,cunitname10; int ia;struct link *next; ;struct link *head;int menu() int ii;printf("please choose a number:n"); printf("input the course :n"); scanf("%s",new->cname);printf("*:n");printf("1 printf("2 printf("3 printf("4 printf(&qu
20、ot;5 printf("* printf("n"); printf("n"); printf("n");create :n"); search :n"); delete :n"); view :n"); quit :n");*printf("n");scanf("%d",&ii);return ii;struct link create()int icount,ij=1;struct link *p,*new;while(1)
21、if(icount)printf(" 輸入頭結(jié)點(diǎn) ");new=(struct link *)malloc(sizeof(struct link); printf("input the course no:n"); scanf("%s",new->cno);printf("input the forecourse :n"); scanf("%s",new->cforecourse);printf("input the course grade:n"); scanf
22、("%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;printf("the fist add success:n");getchar();g
23、etchar();icount=0;elsep->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 search()struct link *p;char ckeyname10; p=head;printf("
24、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");else printf("found it:n");printf("%s,%s,%s,%d,%s,%s",p->cno,p
25、->cname,p->cforecourse,p->ia,p->cunitno,p->cunitna me);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",ckeyname);while(strcmp(ckeyname,p->cname)!=0&&
26、r->next!=NULL)r=r->next;p=p->next;q=q->next; if(r->next=NULL)printf("no this position:n");else printf("found it:n");printf("%s,%s,%s,%d,%s,%s",p->cno,p->cname,p->cforecourse,p->ia,p->cunitno,p->cunitna me); r->next=p->next;printf(&
27、quot;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->cforecourse,p->ia,p->cunitno,p->cunitna me);pri
28、ntf("n");p=p->next;printf("%s,%s,%s,%d,%s,%s",p->cno,p->cname,p->cforecourse,p->ia,p->cunitno,p->cunitna me);void quit()exit(0);void main()int ia=1;head=NULL;while(ia!=5)ia=menu();switch(ia)case 1:create();break;case 2:search();break;case 3:delete();break;cas
29、e 4:output();break;case 5:quit();break; default:printf("input wrong:n"); #include<stdio.h> #include<stdlib.h> #include<string.h> typedef structchar num15;char name20;char credit10;char clas20; char teacher20;student;student pe80;int menu_select()char c;dosystem("cls&
30、quot;); printf("n"); printf("n");n");printf(" 歡迎使用課程信息管理系統(tǒng) printf("n");printf("n");printf(" 課程信息管理系統(tǒng) n"); printf("n");printf(" 1. 增加記錄 n"); printf(" 2. 顯示記錄 n"); printf(" 3. 查詢記錄 n"); printf(" 4.
31、 修改記錄 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-'0');int Input(student per,int n)int i=0;char sign,x10; whi
32、le(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.credit); printf("t 選修課號(hào) :"); scanf("t%s",pern
33、+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");/*格式 */printf(" 課程編號(hào) 課程名稱 學(xué)分 選修課號(hào) 任課教師 n"); printf("n
34、");for(i=1;i<n+1;i+)printf("%-12s%-12s%-15s%-18s%sn",peri-1.num,,peri-1.credit,peri-1.cla s,peri-1.teacher);if(i>1&&i%10=0)printf("tn");printf("t");system("pause");printf("tn");printf("n");system("pause&qu
35、ot;);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"); return(n); for(j=i;j<n-1;j+) strcpy(perj.num,perj+1.num); strcpy(per
36、,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("tn 請(qǐng)選擇查詢方式 :n"); printf("n");printf("1
37、課程編號(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",&m);if(m=1) / 按課程編號(hào)查詢 char s20;int i=0;printf("
38、;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); printf("t 選修課號(hào) : %sn",peri.clas); printf("t 任課教師 :
39、%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) %sn",peri.num);printf("t 學(xué)分: %sn",peri.credit);
40、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)!=0&&i<n) i+; if(i=n)printf
41、("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
溫馨提示
- 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ù)覽,若沒有圖紙預(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024江西贛州市全南縣城市建設(shè)投資有限責(zé)任公司招聘1人筆試參考題庫(kù)附帶答案詳解
- 2024江蘇東海水晶產(chǎn)業(yè)發(fā)展集團(tuán)有限公司招聘擬錄用人員筆試參考題庫(kù)附帶答案詳解
- 2024廣西桂盛金融信息科技服務(wù)有限公司專業(yè)技術(shù)人員常態(tài)化招聘(第一批)筆試參考題庫(kù)附帶答案詳解
- 2025幼兒教育合作合同范本
- 消防燃燒學(xué)基礎(chǔ)知識(shí)2025年消防執(zhí)業(yè)資格考試復(fù)習(xí)指導(dǎo)
- 2025年統(tǒng)計(jì)學(xué)本科期末考試題庫(kù)-基礎(chǔ)概念應(yīng)用與練習(xí)試題
- 2025年大學(xué)統(tǒng)計(jì)學(xué)期末考試題庫(kù):統(tǒng)計(jì)推斷與假設(shè)檢驗(yàn)實(shí)際操作案例分析試題解析與應(yīng)用
- 2025年小學(xué)語(yǔ)文畢業(yè)升學(xué)考試全真模擬卷(文言文閱讀能力提升版)試題
- 2025年小學(xué)教師資格考試綜合素質(zhì)面試題庫(kù)及答案解析詳析
- 2025年滑雪教練職業(yè)技能測(cè)試卷:滑雪運(yùn)動(dòng)生理學(xué)基礎(chǔ)知識(shí)試題
- 《快樂(lè)生活快樂(lè)工作》課件
- 施工現(xiàn)場(chǎng)機(jī)械設(shè)備管理規(guī)定
- 重大火災(zāi)隱患判定方法知識(shí)培訓(xùn)
- 市政道路施工方案投標(biāo)文件(技術(shù)方案)
- 山東《電動(dòng)自行車集中充電設(shè)施建設(shè)規(guī)范》
- 廣東省佛山市S6高質(zhì)量發(fā)展聯(lián)盟2023-2024學(xué)年高一下學(xué)期4月期中考試數(shù)學(xué)
- 杭州本級(jí)公共租賃住房資格續(xù)審申請(qǐng)表Ⅴ
- (完整版)英語(yǔ)四級(jí)詞匯表
- 新浙美版小學(xué)美術(shù)二年級(jí)下冊(cè)教學(xué)計(jì)劃教案及教學(xué)反思
- 2024年消防宣傳月知識(shí)競(jìng)賽考試題庫(kù)300題(含答案)
- 道路旅客運(yùn)輸企業(yè)雙重預(yù)防機(jī)制建設(shè)指導(dǎo)手冊(cè)
評(píng)論
0/150
提交評(píng)論