學生信息管理系統(tǒng)課程設計實驗報告_第1頁
學生信息管理系統(tǒng)課程設計實驗報告_第2頁
學生信息管理系統(tǒng)課程設計實驗報告_第3頁
已閱讀5頁,還剩24頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、WORD格式*大學課程設計報告課程名稱高級語言程序設計設計題目學生信息管理系統(tǒng)專業(yè)計算機科學與技術班級學號*完成日期專業(yè)資料整理WORD格式課程設計任務書設計題目:學生信息管理系統(tǒng)設計設計內容與要求:內容:對學生信息進展管理,學生信息包括學號、*、性別、年齡、學歷、學號、住址、等學號不重復 。要求:(1) 系統(tǒng)以菜單方式工作(2) 學生信息錄入功能 (學生信息用文件保存 ) 。(3) 輸出學生信息、瀏覽學生信息功能。(4) 查詢和排序功能: (至少一種查詢方式 ) ,如按學號查詢、按學歷查詢等。(5) 學生信息刪除、修改功能 (任選項 )。指導教師: _年月日課程設計評語成績:指導教師: _年

2、月日專業(yè)資料整理WORD格式*理工學院課程設計報告【問題描述】學生信息管理軟件設計。 對學生信息進展管理, 學生信息包括: 學號,*,年齡,性別,出生年月,地址, E-mail 等。試設計一個學生信息管理軟件?!靖疽蟆恳?、輸入的形式和輸入值的X圍形式:用 scanf 輸入學生的學號,*,年齡,性別,出生年月,地址,電話, E-mail 。輸入一個學生信息一個回車。用輸入的學號p1->num來控制輸入,當輸入的學號為 0 時,用 break 跳出循環(huán)。即 if(p1->num=0)break。輸入值的X圍:學號、年齡為整型long num; int age;*為字符串型15 個字

3、節(jié) char name15;性別為字符串型, 10 個字節(jié) char sex10;出生為字符串型, 20 個字節(jié) char chushen20;地址為字符串型, 30 個字節(jié) char dizhi30;為字符串型,輸入11 位數字 char email11。二、輸出的形式輸出是以表格的形式輸出,即表格的每一行都能顯示第一個學生的信息,第二行是顯示第二個學生的信息。三、程序所能到達的功能對學生信息進展管理,學生信息包括職學號,*,年齡,性別,出生年月,地址, E-mail 。(1) 系統(tǒng)以菜單方式工作(2) 學生信息錄入功能。專業(yè)資料整理WORD格式1專業(yè)資料整理WORD格式*理工學院課程設計報

4、告(3) 輸出學生信息、瀏覽學生信息功能。(4) 查詢和排序功能: ( 至少一種查詢方式 ) ,如按學號查詢、按*查詢等。(5) 學生信息刪除、修改功能 ( 任選項 ) 。(6) 添加學生信息?!緶y試數據】輸入:設輸入四個學生信息,以最后一個學生的學號為0 來完畢輸入,學號是整型。預期的輸出結果:預期的輸出結果請參見程序后的運行結果?!緮祿嬙臁颗判蛴涗浀臄祿乇聿捎靡痪S數組存儲構造, 每個元素包含 8 個關鍵字段,其類型描述為:#include<stdio.h>#include<malloc.h>/分配 size 字節(jié)的存儲區(qū)#include<string.h

5、>/包含字符串處理函數的頭文件,可以直接調用現有的字符串處理的一系列函數#define len sizeof(struct student)/宏定義求字節(jié)運算符#include<stdlib.h>/清屏功能struct student/聲明一個構造體類型struct studentlong num;/定義學號為 long 型數據char name15;/定義*int age;/定義年齡char sex3;/定義性別char chushen10;/定義出生char dizhi20;/定義出生地址char phone11;/定義專業(yè)資料整理WORD格式2專業(yè)資料整理WORD格式*

6、理工學院課程設計報告char email20;/定義struct student *next;/next 是指針變量,指向構造體變量【算法思想】利用一維構造體存放所有學生的信息,輸入后,在輸出時要對學生按學號的上下排序,然后可以執(zhí)行按學號查詢學生信息,輸入學號,刪除學生信息,輸入學號可以找出該學生信息,然后選擇修改學生信息,如果來了新學生,還可以添加學生信息?!究傮w設計】主菜單包括:輸入函數、學號排序、瀏覽函數、刪除函數、修改函數、添加函數。輸入函數用鍵盤輸入學生信息學生排序按學生學號上下排序輸出學生信息以表格的形式輸出學生信息顯示主菜單刪除學生信息輸入一個學生學號,來刪除該學生信息修改學生信

7、息輸入學號,修改的學生信息添加學生信息在原有的學生上添加學生信息圖 1-1 學生管理總體設計專業(yè)資料整理WORD格式3專業(yè)資料整理WORD格式*理工學院課程設計報告【模塊劃分】一、主函數: main()顯示系統(tǒng)工作菜單,顯示該系統(tǒng)的所有功能。告訴使用者所有將會調用的被調函數,再運用選擇函數 switch 即可根據使用者所輸入的學號進入對應的功能程序。并且對菜單做了一個循環(huán),進展完一個選擇后,按回車鍵可進展清屏功能,把屏幕上除了主菜單以外都清空,然后可以繼續(xù)選擇那些可以使用的功能,這樣可以方便使用者使用,并且每一步都很清晰。以 8 退出系統(tǒng)。二、輸入函數: struct student *cre

8、at()在該程序的前面已經定義了一個構造體structstudent 用來儲存學生的所有信息,學號、年齡、*、性別、出生日期、地址、。定義 p1 和p2,struct student *p1,*p2;p1,p2 是指向 struct student類型數據的指針變量。定義一個 n=0,n 是輸入的個數,主要作用是:如果輸入一個學生信息,首地址指向 p1,head=p1; 否那么 p2 的下一個地址指向 p1, p2 指向 p1. p2->next=p1 ;p2=p1;學號控制循環(huán)。三、排序函數: void paixu(struct student *head)用一個 for語句做循環(huán),不

9、是 NULL的話,指針指向下一個,按學生學號上下排序。整形直接交換,字符型用strcpy交換,類型相當于兩個數據之間的交換。四、輸出函數: void printlist(struct student *head)在主函數里邊用while 控制循環(huán),輸出學生信息,然后指針指向下一個。專業(yè)資料整理WORD格式4專業(yè)資料整理WORD格式*理工學院課程設計報告五、查詢函數: void findList_num(struct student *head)和void findList_num(struct student *head)輸入一個學號或*,做一個 for 循環(huán),即指針 pt 指向第一個地址,再

10、定義一個指針 p1,讓它等于 pt ,他是緊跟著 pt 后面的一個指針,讓 p1->next 不等于NULL,pt 指向下一個地址。這樣就能修改最后一個學生信息了。如果要查詢的學生的學號在學生里,就輸出該學生信息,否那么,就輸出查詢的學生信息不存在。六、刪除函數: int shanchu(struct student *head)輸入一個學號,先找到這個學生的信息。如果輸入的學號在學生信息中,就進展以下循環(huán):如果輸入的是第一個學生的話,就head 等于第二個學生信息;如果輸入的學生信息是最后一個,就讓倒數第二個等于NULL;否那么的話,就讓下一個學生信息覆蓋前一個。如果輸入的學號不在學生

11、信息中,輸出“此學生信息不存在。七、修改函數: structstudent*delList(structstudent*head,longdel_num)輸入要修改的學號,找到該學生并且輸出該學生的信息。然后屏幕上會出現學生信息的所有工程,用 switch 進展選擇修改的工程。 選擇后輸入新的學生信息,用它來覆蓋原來的學生信息。八、添加函數: void insert(struct student *head)用一個 while 語句 while(p2->next!=NULL) 控制循環(huán), p2 的指針指向下一個地址,即 p2=p2->next; 這是找到最后一個地址, 然后開辟動態(tài)

12、存儲區(qū), p1=(structstudent *)malloc(len); 輸入要添加的學號,用學號為 0 來終止循環(huán),如果不為0,就繼續(xù)輸入學生信息?!驹闯绦颉?include<stdio.h>#include<malloc.h>/分配 size 字節(jié)的存儲區(qū)#include<string.h>/包含字符串處理函數的頭文件, 可以直接調用現有的字符串處理的一系列函數專業(yè)資料整理WORD格式5專業(yè)資料整理WORD格式*理工學院課程設計報告#define len sizeof(struct student)/求字節(jié)運算符#include<stdlib.h

13、>/清屏功能FILE *fp;struct student/聲明一個構造體類型struct studentint num;/學號為整型char name20;/*為字符串char genter10;/性別為字符串int age;/年齡為整型char xueli20;/學歷為字符串int gongzi;/學號為整型char address30;/地址為字符串char phone11;/為字符串struct student *next;/next 是指針變量,指向構造體變量;void menu()printf("= 學生信息管理系統(tǒng) =nn");printf("

14、1、錄入學生信息 n");printf("2、瀏覽學生信息 n");printf("3、查詢學生信息 n");printf("4、刪除學生信息 n");printf("5、插入學生信息 n");printf("6、修改學生信息 n");printf("7、排序學生信息 n");printf("8、退出管理系統(tǒng) n");printf("=n");struct student *creat()/ 錄入學生信息專業(yè)資料整理WORD格

15、式6專業(yè)資料整理WORD格式*理工學院課程設計報告int n;struct student *head;struct student *p1,*p2;n=0;p1=p2=(struct student *) malloc(len);scanf("%dt%dt%st%st%st%st%st%s",&p1->num,&p1->age,p1->name,p1->sex,p 1->chushen,p1->dizhi,p1->phone,p1->email);head=NULL;while(p1->num!=0)n

16、=n+1;if(n=1) head=p1;else p2->next=p1;p2=p1;p1=(struct student *)malloc(len);scanf("%dt%dt%st%st%st%st%st%s",&p1->num,&p1->age,p1->name,p1->s ex,p1->chushen,p1->dizhi,p1->phone,p1->email);p2->next=NULL;return(head);void insert(struct student *head) /插入

17、學生信息int search_num;struct student *p,*q,*s;專業(yè)資料整理WORD格式7專業(yè)資料整理WORD格式*理工學院課程設計報告p=head;printf(" 在哪個學生前插入請輸入學號: n");scanf("%d",&search_num);while(p!=NULL)&&(p->num!=search_num)q=p;p=p->next;s=(struct student *)malloc(len);q->next=s;system("cls");print

18、f(" 請輸入學生信息 :n");printf(" 學號 t 年齡 t * t 性別 t 出生 t 地址 t te-mailn");scanf("%dt%dt%st%st%st%st%st%s",&s->num,&s->age,s->name,s->sex,s->chus hen,s->dizhi,s->phone,s->email);s->next=p;void printList(struct student *head)/瀏覽全部學生信息struct stud

19、ent *p;p=head;if(head=NULL)printf(" 沒有學生信息 !n");elsedo專業(yè)資料整理WORD格式8專業(yè)資料整理WORD格式*理工學院課程設計報告fread(p,len,1,fp);printf("%dt%dt%st%st%st%st%st%sn",p->num,p->age,p->name,p->sex,p->chus hen,p->dizhi,p->phone,p->email);p=p->next;while(p!=NULL);void findList_num

20、(struct student *head,long search_num) /按學號查找struct student *p;p=head;while(p!=NULL)&&(p->num!=search_num)p=p->next;if(p!=NULL)printf("%dt%dt%st%st%st%st%st%sn",p->num,p->age,p->name,p->sex,p->chus hen,p->dizhi,p->phone,p->email);elseprintf(" 沒有該學

21、生信息 !n");void findList_name(struct student *head,char *search_name) /按*查找struct student *p;專業(yè)資料整理WORD格式9專業(yè)資料整理WORD格式*理工學院課程設計報告int cmp1=0,cmp=0;p=head;while(p!=NULL)if(strcmp(p->name,search_name)!=0)p=p->next;cmp+;elseprintf("%dt%dt%st%st%st%st%st%sn",p->num,p->age,p->n

22、ame,p->sex,p->chus hen,p->dizhi,p->phone,p->email);p=p->next;cmp1=1;if(cmp!=0&&cmp1=0)printf(" 沒有該學生信息 !n");void xiugai(struct student *p1,long xiu_num)/修改學生信息struct student *p2;p2=p1;while(p2!=NULL)&&(p2->num!=xiu_num)p2=p2->next;if(p2!=NULL)scanf(&

23、quot;%dt%dt%st%st%st%st%st%s",&p2->num,&p2->age,p2->name,p2->s專業(yè)資料整理WORD格式10專業(yè)資料整理WORD格式*理工學院課程設計報告ex,p2->chushen,p2->dizhi,p2->phone,p2->email);elseprintf(" 沒有該學生信息 !n");struct student *delList(struct student *head,long del_num) / 刪除學生信息struct student

24、*p,*q;p=head;q=head;while(p &&(p->num != del_num)q=p;p=p->next;if(p=NULL)printf(" 無此學號 !n");elseif(p = head)head = p->next;free(p);elseq->next = p->next;free(p);專業(yè)資料整理WORD格式11專業(yè)資料整理WORD格式*理工學院課程設計報告return head;void paixu(struct student *head)/按學號排序struct student *p,*

25、f,*t;char ch100;int i;t=f=p=head;for(p=head;p->next!=NULL;p=p->next)for(t=head,f=t->next;t->next!=NULL;t=t->next,f=f->next)if(t->num>f->num>0)i=t->num;t->num=f->num;f->num=i;i=t->age;t->age=f->age;f->age=i;strcpy(ch,t->name);strcpy(t->name,

26、f->name);strcpy(f->name,ch);專業(yè)資料整理WORD格式12專業(yè)資料整理WORD格式*理工學院課程設計報告strcpy(ch,t->sex);strcpy(t->sex,f->sex);strcpy(f->sex,ch);strcpy(ch,t->chushen);strcpy(t->chushen,f->chushen);strcpy(f->chushen,ch);strcpy(ch,t->dizhi);strcpy(t->dizhi,f->dizhi);strcpy(f->dizhi

27、,ch);strcpy(ch,t->phone);strcpy(t->phone,f->phone);strcpy(f->phone,ch);strcpy(ch,t->email);strcpy(t->email,f->email);strcpy(f->email,ch);/ return head;void save(struct student *head) /保存為磁盤文件struct student *p;if(fp=fopen("keshe","w")=NULL)/翻開一個文件專業(yè)資料整理WORD

28、格式13專業(yè)資料整理WORD格式*理工學院課程設計報告printf("cannot open this filen");exit(0);p=head;while(p!=NULL)fprintf(fp,"%dn",p->num);fprintf(fp,"%dn",p->age);fprintf(fp,"%sn",p->name);fprintf(fp,"%sn",p->sex);fprintf(fp,"%sn",p->chushen);fprint

29、f(fp,"%sn",p->dizhi);fprintf(fp,"%sn",p->phone);fprintf(fp,"%sn",p->email);p=p->next;fclose(fp);struct student *read()/從磁盤讀取文件struct student *head=NULL;struct student *p=NULL;struct student *t=NULL;int a;/fp=fopen("keshe","r");if(fp=fopen

30、("keshe","r")=NULL)/翻開一個文件printf("cannot open this filen");專業(yè)資料整理WORD格式14專業(yè)資料整理WORD格式*理工學院課程設計報告exit(0);while(1)t=(struct student *)malloc(len);a=fscanf(fp,"%dt%dt%st%st%st%st%st%s",&t->num,&t->age,t->name,t->se x,t->chushen,t->dizhi,

31、t->phone,t->email);if(a=0|a=-1)return head;t->next=NULL;if(p=NULL)p=t;head=t;elsep->next=t;p=p->next;p->next=NULL;fclose(fp);void main()/主函數int code=0;struct student *pt = NULL;專業(yè)資料整理WORD格式15專業(yè)資料整理WORD格式*理工學院課程設計報告for(code=1;code+)/控制循環(huán)menu();/調用菜單函數printf(" 請輸入序號 :n");/提

32、示輸入序號scanf("%d",&code);system("cls");/清屏下邊也是這樣的功能switch(code)/選擇序號進展功能選擇case 1:system("cls");printf("=輸入學生信息=n");printf("-n");printf(" 學號 t 年齡 t * t 性別 t 出生 t 地址 t te-mailn");pt=creat();/調用輸入函數save(pt);/將數據存儲到磁盤中system("cls");

33、printf("=輸入學生信息=n");printf("-n");printf("*成功輸入學生信息 *!nn");printf(" 按回車鍵返回主菜單 n");getchar();getchar();/按回車鍵返回system("cls");break;case 2:專業(yè)資料整理WORD格式16專業(yè)資料整理WORD格式*理工學院課程設計報告system("cls");printf("=學生信息表=n");printf("-n");pr

34、intf(" 學號 t 年齡 t * t 性別 t 出生 t 地址 t te-mailn");printList(read();/調用輸出函數是從磁盤中讀出的printf("=n");printf("-n");printf("n 按回車鍵返回主菜單 n");getchar();getchar();system("cls");break;case 3:int search=0;system("cls");printf("=查詢學生信息=n");printf(

35、"-n");while(search!=3)/進入查詢功能函數printf("1 、按學號查詢 n2、按*查詢 n3、退出查詢 n");scanf("%d",&search);/ 插入查找的方式switch(search)專業(yè)資料整理WORD格式17專業(yè)資料整理WORD格式*理工學院課程設計報告case 1:/選擇學號查詢long search_num;system("cls");printf(" 請輸入學生學號 n");scanf("%d",&search_

36、num);system("cls");printf("=查詢結果=n");printf("-n");printf(" 學號 t 年齡 t * t 性別 t 出生 t 地址 t te-mailn");findList_num(read(),search_num);/調用查找函數, 將數據從磁盤中讀出printf("=n");printf("-n");printf("n 按回車鍵返回查詢菜單n");getchar();getchar();system(&quo

37、t;cls");break;case 2:/按*查找char search_name15;system("cls");printf(" 請輸入學生* n");scanf("%s",search_name);/輸入要查找的學生的*system("cls");printf("=查詢結果 =n");專業(yè)資料整理WORD格式18專業(yè)資料整理WORD格式*理工學院課程設計報告printf("-n");printf(" 學號 t 年齡 t * t 性別 t 出生 t

38、地址 t te-mailn");findList_name(read(),search_name);/ 調 用 姓 名 查 找 函 數printf("=n");printf("-n");printf("n 按回車鍵返回查詢菜單n");getchar();getchar();system("cls");system("cls");break;case 4:/刪除學生信息long del_num;system("cls");printf("=刪除學生信息=n&

39、quot;);printf("-n");printf(" 請輸入要刪除學生信息的學號:n");scanf("%d",&del_num);/輸入要刪除的學號system("cls");pt=delList(read(),del_num);/調用刪除函數save(pt);printf("=刪除結果專業(yè)資料整理WORD格式19專業(yè)資料整理WORD格式*理工學院課程設計報告=n");printf("-n");printf(" 學號為 %d 的學生信息成功刪除 n&q

40、uot;,del_num);printf("n 按回車鍵返回主菜單 n");getchar();getchar();system("cls");break;case 5:/插入函數system("cls");printf("=插入學生信息=n");printf("-n");insert(pt);/調用輸入函數save(pt);/保存到磁盤中system("cls");printf("=插入學生信息=n");printf("-n");pr

41、intf("*插入學生信息成功 *!nn");printf(" 按回車鍵返回主菜單 n");getchar();getchar();system("cls");break;case 6:/修改函數long search_num;專業(yè)資料整理WORD格式20專業(yè)資料整理WORD格式*理工學院課程設計報告system("cls");printf(" 請輸入要修改的學生學號:n");scanf("%d",&search_num); /輸入要修改的學生學號 system(&q

42、uot;cls");printf("=修改學生信息=n");printf("-n");printf(" 學號 t 年齡 t * t 性別 t 出生 t 地址 t te-mailn");findList_num(read(),search_num); /調用查找函數 printf("n");printf(" 請輸入修改信息 :n");printf(" 學號 t 年齡 t * t 性別 t 出生 t 地址 t te-mailn");pt=read();xiugai(pt

43、,search_num);/調用修改函數save(pt);/保存printf("=n");printf("-n");printf("*修改學生信息成功 *!nn");printf("n 按回車鍵返回查詢菜單n");getchar();getchar();system("cls");break;case 7:/排序函數system("cls");printf("按學號從小到大排序專業(yè)資料整理WORD格式21專業(yè)資料整理WORD格式*理工學院課程設計報告nn");printf("=學生信息表=n");printf("-n");printf(" 學號 t 年齡 t * t 性別 t 出生 t 地址 t te-mailn");pt=read();paixu(pt);/調用排序函數printList(pt);/調用顯示函數save(

溫馨提示

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

評論

0/150

提交評論