




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、C 程序 學(xué)生管理系統(tǒng)/* Note:Your choice is C IDE */#include "stdio.h"#include "stdlib.h"#include "string.h" typedef struct student / 定義學(xué)生 char name10;int number;char sex2;int math;int eglish;int clanguge;int average; student;typedef struct unit / 定義接點(diǎn)student date;struct unit * n
2、ext; unit;unit * build() / 建立鏈表并返回指針unit *p;if (p =(unit * )malloc( sizeof (unit) =NULL) printf( "=>初始化失??! ");return 0;else p-> next =NULL;p-> date . number=0; / 頭結(jié)點(diǎn)存放學(xué)生人數(shù) printf( " 初始化成功! n" );return p;void add(unit * head) / 增加學(xué)生unit *p,*q;int m,n =0;q=head-> next;p
3、=(unit * )malloc( sizeof (unit);printf( "=> 請(qǐng)輸入新生姓名! n" );gets(p -> date . name);fflush(stdin);printf( "=> 請(qǐng)輸入學(xué)號(hào)! n" );while (n =0) scanf( "%d", &m);fflush(stdin);if (q =NULL) n=1;while (q)if (q -> date . number=m)printf( "=> 你輸入的學(xué)號(hào)與已有同學(xué)的學(xué)號(hào)相同,請(qǐng)重新
4、輸入! n" );q =head-> next;break ;elseq =q-> next;if (q =NULL) n=1;p-> date . number=m;printf( "=> 請(qǐng)輸入性別! n" );gets(p -> date . sex);fflush(stdin);printf( "=> 請(qǐng)輸入數(shù)學(xué)成績(jī) n" );scanf( "%d", &m);fflush(stdin);p-> date . math=m;printf( "=> 請(qǐng)輸
5、入英語(yǔ)成績(jī) n" );scanf( "%d", &m);fflush(stdin);p-> date . eglish =m;printf("=>請(qǐng)輸入c語(yǔ)言成績(jī)n");scanf( "%d",&m);fflush(stdin);p->date. clanguge=m;p->date.average=(p->date.math+p->date.eglish +p->date.clanguge); q=head->next;head-> next =p;p-
6、> next =q; head-> date . number+;void deletion(unit* head) / 刪除一名學(xué)生unit * p=head-> next, * q=head;char N10;printf( "=> 請(qǐng)輸入你想刪除的學(xué)生姓名! n" ); gets(N);fflush(stdin);if (p =NULL)printf( "=> 系統(tǒng)無(wú)學(xué)生可刪除! n" );while (p)if (strcmp(p ->date . name,N)=0)q-> next =p-> n
7、ext; head-> date . number- ;printf("=>刪除s成功! n" ,p->date .name); free(p); break;elsep=p->next; q=q->next; if (p =NULL) printf( "=>你要?jiǎng)h除的學(xué)生不存在 , 刪除失敗! n" );int display(unit *head)/ 顯示學(xué)生信息unit *p=head->next;int m,n=0;char N10;if (p =NULL)printf( "= >系統(tǒng)無(wú)學(xué)
8、生! n" ); return 0;while (n =0)printf(*n");printf( "=>請(qǐng)選擇你的操作! n" );printf( "=>ttt1. 顯示所有 t2. 按姓名查找 nttt3. 按學(xué)號(hào)查找 t4. 返回主菜單 n" );scanf( "%d", &m); fflush(stdin);switch (m)case 1:printf( "n=>該系統(tǒng)擁有名學(xué)生!nn" ,head->date.number);p =head->
9、next;printf( "t姓名t學(xué)號(hào)t性別t數(shù)學(xué)t英語(yǔ)tc語(yǔ)言t綜合 nn" );while (p)printf( "t%st%dt%st%dt%dt%dt%dn" ,p->date. name,p-> date . numb er,p ->date. sex,p ->date.math,p-> date . eglish,p ->date. clanguge,p ->date. average);p=p->next;break;case 2:printf("=>請(qǐng)輸入查找姓名!n&qu
10、ot; );gets(N);fflush(stdin);p =head-> next;while (p)if (strcmp(p ->date. name,N)=0)printf( "t姓名t學(xué)號(hào)t性別t數(shù)學(xué)t英語(yǔ)tc語(yǔ)言t 綜合n");printf( "t%st%dt%st%dt%dt%dt%dn" ,p->date. name,p-> date . numb er,p ->date. sex,p ->date.math,p-> date . eglish,p->date. clanguge,p ->
11、;date. average); break;elsep=p-> next;if (p =NULL)printf( "=>你要查的學(xué)生不存在! ");break ;case 3: printf( "=> 請(qǐng)輸入查找學(xué)號(hào)! n" );scanf( "%d", &m);fflush(stdin);p =head-> next;while (p)if (p -> date . number=m) printf( "t姓名t學(xué)號(hào)t性別t數(shù)學(xué)t英語(yǔ)tc語(yǔ)言t 綜合 n" );printf
12、( "t%st%dt%st%dt%dt%dt%dn" ,p->date. name,p->date. numb er,p -> date . sex,p -> date . math,p-> date . eglish,p ->date. clanguge,p ->date. average);break ;elsep=p->next;if (p =NULL)printf( "=>你要查的學(xué)生不存在! n" );break ;case 4:n =1; break ;return 1;int range
13、(unit * head) / 排序unit * p=head, * q=head-> next;int n,i,m =head-> date . number;printf(*n");按成績(jī) nn" "););printf( "ttt1. 按學(xué)號(hào) t2. printf( "=>請(qǐng)選擇操作! n scanf( "%d", &n);fflush(stdin);if (q =NULL) printf( "=> 無(wú)學(xué)生可排序! n" );return 0;switch (n) c
14、ase 2: for (i =0;i <m;i +)/ 按總分排序 p=head;q =head-> next; while (q -> next) if (q -> date . average) <(q ->next -> date . average) p-> next =q-> next; p=p-> next; q-> next =p-> next; p-> next =q; else p=p-> next;q =q-> next;break ;case 1: for (i =0;i <=
15、m;i +)/ 按學(xué)號(hào)排序 p=head;q =head-> next; while (q -> next) if (q -> date . number)>(q -> next -> date . number) p-> next =q-> next; p=p-> next;q-> next =p-> next; p-> next =q;elsep=p->next;q =q-> next;break ;printf( return"=排序成功! n" ); 1;void menu()pri
16、ntf(主菜單*n");printf( "ttt1. 新建系統(tǒng) t2. 添加學(xué)生 nttt3. 刪除學(xué)生 t4. 查看信息nttt5.排列順序t6.讀取信息nttt7.保存信息t8.退出系統(tǒng)n");printf( "=請(qǐng)選擇你的操作! n" );int save(unit* head) / 保存FILE *fp;unit *p;p =head;if (fp =fopen( 學(xué)生","wb+") =NULL)printf( "=>保存失?。?");return 0;while (p)fwri
17、te( &(p -> date) , sizeof (student),1,fp); p =p->next;printf( "=>保存成功! ");fclose(fp);return 1; unit * read() / 讀入系統(tǒng)學(xué)生信息int i;unit * p, * q, * head;FILE *fp;if (head =(unit * )malloc( sizeof (unit) =NULL) printf( "=>開辟空間失敗! ");exit(1);elsehead-> next =NULL;head-
18、> date . number=0; / 頭結(jié)點(diǎn)存放學(xué)生人數(shù) q=head;if (fp =fopen(學(xué)生" , "rb" ) =NULL) printf( "=> 系統(tǒng)無(wú)學(xué)生! n" ); return 0;fread( &(q -> date), sizeof (student),1,fp);for (i =0;i <head-> date . number;i +) if (p =(unit * )malloc( sizeof (unit) =NULL) printf( "=>讀值失敗! ");exit(1);fread( &(p -> date), sizeof (student),1,fp); p -> next =q-> next;q -> next =p; fclose(fp); return head;void main()int m=0,n, i; unit* head;printf(H*nn");printf(H*printf( "ttt* 歡迎使用學(xué)生成績(jī)管理系統(tǒng) * n" );printf( "
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 基于人工智能的個(gè)性化醫(yī)療解決方案
- 開發(fā)民俗體驗(yàn)的背景意義及必要性
- 掌握英語(yǔ)學(xué)習(xí)策略
- 老舊廠區(qū)改造項(xiàng)目投融資與財(cái)務(wù)方案
- 2025雇傭合同 合同協(xié)議
- 共育明日之星
- 博士探索:科研之路
- 2025年熱塑性彈性體項(xiàng)目規(guī)劃申請(qǐng)報(bào)告
- 財(cái)務(wù)報(bào)銷流程規(guī)范培訓(xùn)
- 石油監(jiān)事考試題庫(kù)及答案
- 消控室考核試題及答案
- 2025年湖南省永州市初中學(xué)業(yè)水平模擬考試化學(xué)試卷(一)(含答案)
- 2025年甘肅省蘭州市學(xué)府致遠(yuǎn)學(xué)校中考押題卷(二)英語(yǔ)試題(含答案)
- 公司項(xiàng)目薪資管理制度方案
- 統(tǒng)編版2024-2025學(xué)年語(yǔ)文三年級(jí)下冊(cè)期末測(cè)試卷(含答案)
- 預(yù)防混料管理
- 現(xiàn)場(chǎng)工程師人才培養(yǎng)路徑研究
- 2025屆湖北省咸寧市三校中考化學(xué)模擬試卷含解析
- 浙江省東陽(yáng)市文旅投資集團(tuán)有限公司招聘高頻重點(diǎn)模擬試卷提升(共500題附帶答案詳解)
- 發(fā)展與教育心理學(xué)真題考試卷(有答案)
- 中醫(yī)五谷養(yǎng)生法提高免疫力的飲食方案
評(píng)論
0/150
提交評(píng)論