學(xué)生成績管理系統(tǒng)代碼_第1頁
學(xué)生成績管理系統(tǒng)代碼_第2頁
學(xué)生成績管理系統(tǒng)代碼_第3頁
免費(fèi)預(yù)覽已結(jié)束,剩余6頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

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 * next; unit;unit * build() / 建立鏈表并返回指

2、針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=(unit * )malloc( sizeof (unit);printf( = 請輸入新生姓名! n );gets(p - date . name)

3、;fflush(stdin);printf( = 請輸入學(xué)號! n );while (n =0) scanf( %d, &m);fflush(stdin);if (q =NULL) n=1;while (q)if (q - date . number=m)printf( = 你輸入的學(xué)號與已有同學(xué)的學(xué)號相同,請重新輸入! n );q =head- next;break ;elseq =q- next;if (q =NULL) n=1;p- date . number=m;printf( = 請輸入性別! n );gets(p - date . sex);fflush(stdin);printf

4、( = 請輸入數(shù)學(xué)成績 n );scanf( %d, &m);fflush(stdin);p- date . math=m;printf( = 請輸入英語成績 n );scanf( %d, &m);fflush(stdin);p- date . eglish =m;printf(=請輸入c語言成績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- next =q; h

5、ead- date . number+;void deletion(unit* head) / 刪除一名學(xué)生unit * p=head- next, * q=head;char N10;printf( = 請輸入你想刪除的學(xué)生姓名! n ); gets(N);fflush(stdin);if (p =NULL)printf( = 系統(tǒng)無學(xué)生可刪除! n );while (p)if (strcmp(p - date . name,N)=0)q- next =p- next; head- date . number- ;printf(=刪除s成功! n ,p-date .name); free(p

6、); 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)無學(xué)生! n ); return 0;while (n =0)printf(*n);printf( =請選擇你的操作! n );printf( =ttt1. 顯示所有 t2. 按姓名查找 nttt3. 按學(xué)號查找 t4. 返回主菜單 n );scanf( %

7、d, &m);fflush(stdin);switch (m)case 1:printf( n=該系統(tǒng)擁有名學(xué)生!nn ,head-date.number); p =head- next;printf( t姓名t學(xué)號t性別t數(shù)學(xué)t英語tc語言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;ca

8、se 2:printf( =請輸入查找姓名! n ); gets(N); fflush(stdin);p =head- next;while (p)if (strcmp(p -date. name,N)=0)printf( t姓名t學(xué)號t性別t數(shù)學(xué)t英語tc語言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 -date. average); break;elsep=p- nex

9、t;if (p =NULL)printf( =你要查的學(xué)生不存在! );break ;case 3: printf( = 請輸入查找學(xué)號! n );scanf( %d, &m);fflush(stdin);p =head- next;while (p)if (p - date . number=m) printf( t姓名t學(xué)號t性別t數(shù)學(xué)t英語tc語言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 -d

10、ate. clanguge,p -date. average);break ;elsep=p-next;if (p =NULL)printf( =你要查的學(xué)生不存在! n );break ;case 4:n =1; break ;return 1;int range(unit * head) / 排序unit * p=head, * q=head- next; int n,i,m =head- date . number;printf(*n);按成績 nn ););printf( ttt1. 按學(xué)號 t2. printf( =請選擇操作! n scanf( %d, &n);fflush(std

11、in);if (q =NULL) printf( = 無學(xué)生可排序! n );return 0; switch (n)case 2: for (i =0;i next; while (q - next)if (q - date . average) 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 next; while (q - next) if (q - date . numbe

12、r)(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()printf(主菜單*n);printf( ttt1. 新建系統(tǒng) t2. 添加學(xué)生 nttt3. 刪除學(xué)生 t4. 查看信息nttt5.排列順序t6.讀取信息nttt7.保存信息t8.退出系統(tǒng)n);printf( =請選擇你的操作! n );int save(unit* head) /

13、保存FILE *fp;unit *p;p =head;if (fp =fopen( 學(xué)生,wb+) =NULL)printf( =保存失??! );return 0;while (p)fwrite( &(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

14、( =開辟空間失??! );exit(1);elsehead- next =NULL;head- date . number=0; / 頭結(jié)點(diǎn)存放學(xué)生人數(shù) q=head;if (fp =fopen(學(xué)生 , rb ) =NULL) printf( = 系統(tǒng)無學(xué)生! n ); return 0;fread( &(q - date), sizeof (student),1,fp);for (i =0;i date . number;i +) if (p =(unit * )malloc( sizeof (unit) =NULL) printf( =讀值失??! );exit(1);fread( &(p

15、 - 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;*nn);printf( ttt* 歡迎使用學(xué)生成績管理系統(tǒng) * n );printf( ntttttttt 編譯員:岳英明 nn );printf(= 正在讀取系統(tǒng)信息 n );if (head =read() =0)printf( =是否新建? n );printf( ttt 是(1) tt 否(2) n); scanf( %d,&i); fflush(stdin);if (i =1) head =build(); else if (i =2) exit(1);elseprintf( =信息導(dǎo)入成功! );while (m=0)menu(); scanf( %d,&n); fflush(stdin);switch (n)case 1: hea

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論