




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
實用標準文案C程序 學生管理系統/*Note:YourchoiceisCIDE*/#include "stdio.h"#include"stdlib.h"#include"string.h"typedef struct student//定義學生{charname[10];intnumber;charsex[2];intmath;integlish;intclanguge;intaverage;}student;typedef struct unit//定義接點{studentdate;精彩文檔實用標準文案structunit*next;}unit;unit*build()//建立鏈表并返回指針{unit*p;if((p=(unit*)malloc(sizeof(unit)))==NULL){printf("=>初始化失敗!");return0;}else{p->next=NULL;p->date.number=0;//頭結點存放學生人數printf("初始化成功!\n");return p;}}voidadd(unit *head)//增加學生{精彩文檔實用標準文案unit*p,*q;intm,n=0;q=head->next;p=(unit*)malloc(sizeof(unit));printf("=>請輸入新生姓名!\n");gets(p->);fflush(stdin);printf("=>請輸入學號!\n");while(n==0){scanf("%d",&m);fflush(stdin);if(q==NULL)n=1;while(q){if(q->date.number==m){printf("=>你輸入的學號與已有同學的學號相同,請重新輸入!\n");q=head->next;break;}else精彩文檔實用標準文案{q=q->next;if(q==NULL)n=1;}}}p->date.number=m;printf("=>請輸入性別!\n");gets(p->date.sex);fflush(stdin);printf("=>請輸入數學成績\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;head->date.number++;}voiddeletion(unit *head)//刪除一名學生{unit*p=head->next,*q=head;charN[10];printf("=>請輸入你想刪除的學生姓名! \n");gets(N);fflush(stdin);if(p==NULL)printf("=>系統無學生可刪除!\n");while(p){if(strcmp(p->,N)==0){q->next=p->next;head->date.number--;printf("=>刪除%s成功!\n",p->);free(p);break;精彩文檔實用標準文案}else{p=p->next;q=q->next;if(p==NULL)printf("=>你要刪除的學生不存在,刪除失敗!\n");}}}intdisplay(unit *head)//顯示學生信息{unit*p=head->next;intm,n=0;charN[10];if(p==NULL){printf("=>系統無學生!\n");return 0;精彩文檔實用標準文案}while(n==0){printf("******************************************************************************\n" );printf("=>請選擇你的操作!\n");printf("=>\t\t\t1. 顯示所有\t2.按姓名查找\n\t\t\t3. 按學號查找\t4.返回主菜單\n");scanf("%d",&m);fflush(stdin);switch(m){case1:printf("\n=> 該系統擁有%d名學生!\n\n",head->date.number);p=head->next;printf("\t姓名\t學號\t性別\t數學\t英語\tc語言\t綜合\n\n");while(p){printf("\t%s\t%d\t%s\t%d\t%d\t%d\t%d\n" ,p->,p->date.精彩文檔實用標準文案number,p->date.sex,p->date.math,p->date.eglish,p->date.clanguge,p->date.average);p=p->next;}break;case2:printf("=>請輸入查找姓名!\n");gets(N);fflush(stdin);p=head->next;while(p){if(strcmp(p->,N)==0){printf("\t姓名\t學號\t性別\t數學\t英語\tc語言\t綜合\n");printf("\t%s\t%d\t%s\t%d\t%d\t%d\t%d\n" ,p->,p->date.number,p->date.sex,p->date.math,p->date.eglish,p->date.clanguge,p->date.average);break;精彩文檔實用標準文案}else{p=p->next;if(p==NULL)printf("=>你要查的學生不存在! ");}}break;case3:printf( "=>請輸入查找學號!\n");scanf("%d",&m);fflush(stdin);p=head->next;while(p){if(p->date.number==m){printf("\t姓名\t學號\t性別\t數學\t英語\tc語言\t綜合\n");printf("\t%s\t%d\t%s\t%d\t%d\t%d\t%d\n" ,p->,p->date.number,p->date.sex,p->date.math,精彩文檔實用標準文案p->date.eglish,p->date.clanguge,p->date.average);break;}else{p=p->next;if(p==NULL)printf("=>你要查的學生不存在! \n");}}break;case4:n=1;break;}}return 1;}intrange(unit *head)//排序精彩文檔實用標準文案{unit*p=head,*q=head->next;intn,i,m=head->date.number;printf("*******************************************************************************\n" );printf("\t\t\t1. 按學號\t2.按成績\n\n");printf("=>請選擇操作!\n》");scanf("%d",&n);fflush(stdin);if(q==NULL){printf("=>無學生可排序!\n");return 0;}switch(n){case2: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;case1:for(i=0;i<=m;i++)//按學號排序{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;}else{p=p->next;q=q->next;}}}break;}printf("=>排序成功!\n");return 1;}voidmenu(){printf("\n********************************* 主菜單***************************************\n" );精彩文檔實用標準文案printf("\t\t\t1. 新建系統\t2.添加學生\n\t\t\t3. 刪除學生\t4.查看信息\n\t\t\t5. 排列順序\t6.讀取信息\n\t\t\t7. 保存信息\t8.退出系統\n");printf("=>請選擇你的操作!\n");}intsave(unit *head)//保存{FILE*fp;unit*p;p=head;if((fp=fopen( 學生","wb+"))==NULL){printf("=>保存失敗!");return0;}while(p){fwrite(&(p->date),sizeof(student),1,fp);p=p->next;}printf("=>保存成功!");精彩文檔實用標準文案fclose(fp);return 1;}unit*read()//讀入系統學生信息{inti;unit*p,*q,*head;FILE*fp;if((head=(unit*)malloc(sizeof(unit)))==NULL){printf("=>開辟空間失敗!");exit(1);}else{head->next=NULL;head->date.number=0;//頭結點存放學生人數}q=head;if((fp=fopen( 學生","rb"))==NULL)精彩文檔實用標準文案{printf("=>系統無學生!\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;}voidmain(){intm=0,n,i;unit*head;精彩文檔實用標準文案printf("********************************************************************************\n\n" );printf("\t\t\t* 歡迎使用學生成績管
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 計算機四級數據庫考試的試題及答案有效性
- 測試文檔及其重要性試題及答案
- 領導者在團隊中的影響力與實踐分析試題及答案
- 2025深圳合同試用期規定
- 2025農村電商扶貧資金申請項目實施中的政策支持與地方創新報告
- 旅游產業園運營管理方案
- 新能源汽車電池熱管理系統節能降耗技術探討報告
- 虛擬現實(VR)教育應用項目可行性研究報告
- 高鐵列車智能調度系統企業制定與實施新質生產力項目商業計劃書
- 中國瘰疬片行業市場前景預測及投資價值評估分析報告
- 香港借貸合同協議
- 酒店消防安全知識培訓
- 書法中考試題及答案
- 經營崗位筆試題目及答案
- 農行反洗錢與制裁合規知識競賽考試題庫大全-上下
- DGTJ08-202-2020鉆孔灌注樁施工規程 上海市
- 充電樁基本知識課件
- 中職電子類面試題及答案
- 作風建設學習教育讀書班交流發言提綱
- 2025年社會工作者職業水平考試中級實務模擬試卷:社會工作專業能力與團隊協作能力試題
- 2025年《AI人工智能知識競賽》題庫及答案解析
評論
0/150
提交評論