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

下載本文檔

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

文檔簡介

1、<p><b>  C語言課程設計報告</b></p><p>  題目:學生信息管理系統(tǒng)</p><p>  院系名稱:計算機科學系</p><p><b>  一. 設計目的</b></p><p>  1. 通過本次試驗,能更好的對鏈表結(jié)構(gòu)體、部分的相關知識有一個系統(tǒng)的復習和提高。&

2、lt;/p><p>  2. 從實驗中找出自己在對整體程序設計上的缺陷,并在以后加以改進。</p><p><b>  二. 設計內(nèi)容</b></p><p>  編寫學生信息管理系統(tǒng),包含數(shù)據(jù)的插入、顯示、修改、刪除、查找,文件的讀寫。</p><p><b>  三.概要設計</b></p&g

3、t;<p><b>  1.功能模塊圖</b></p><p><b>  (1)用戶進入模塊</b></p><p><b>  (2) 主菜單</b></p><p><b>  (3) 插入模塊</b></p><p>  當用戶輸入選

4、擇使用的功能為 1時,進入插入功能顯示如下界面:</p><p>  在輸入完成后按enter鍵顯示如下:</p><p>  輸入y則繼續(xù)輸入,輸入n則返回主菜單。</p><p><b>  (4) 查詢模塊</b></p><p>  當用戶輸入選擇使用的功能為 2時,進入查詢功能顯示如下界面:</p>

5、<p>  輸入學號 1則顯示:</p><p>  按enter 返回主菜單。</p><p><b>  (5)顯示模塊</b></p><p>  當用戶輸入選擇使用的功能為 3時,進入顯示所有信息功能顯示如下界面:</p><p>  按enter 鍵返回主菜單。。</p><p

6、><b>  (6) 刪除模塊</b></p><p>  當用戶輸入選擇使用的功能為 4時,進入刪除功能顯示如下界面:</p><p>  輸入要刪除的學號信息,按enter 鍵,系統(tǒng)就會進行刪除信息,刪除成功后顯示如下:</p><p>  按enter鍵返回主菜單。</p><p><b>  (7

7、) 修改模塊</b></p><p>  當用戶輸入選擇使用的功能為 5時,進入修改功能顯示如下界面:</p><p>  修改完成后輸入n返回主菜單,按y繼續(xù)修改。</p><p><b>  (8)退出</b></p><p>  若要退出,在主菜單界面輸入 6 則會退出本系統(tǒng)。</p>

8、<p>  2.各個模塊詳細的功能描述。</p><p>  (1) 用戶進入界面:每次都進入必須輸入密碼才能進入主菜單。</p><p>  (2) 主菜單:通過數(shù)據(jù)的錄入(或打開存儲的文件)實現(xiàn)信息的修改、插入、刪除、</p><p>  查找,然后打印輸出。</p><p><b>  四.詳細設計</b>

9、;</p><p>  1.功能函數(shù)的調(diào)用關系圖</p><p><b>  2.重點設計及編碼</b></p><p><b>  1.密碼輸入:</b></p><p><b>  相關代碼:</b></p><p>  void first()&l

10、t;/p><p><b>  { </b></p><p><b>  int i;</b></p><p><b>  do</b></p><p>  {printf("***************學生信息管理系統(tǒng)中**************\n");

11、</p><p>  printf("*******************系統(tǒng)初始化******************\n");</p><p>  printf("初始密碼:");</p><p>  scanf("%d",&i);</p><p>  fflush(s

12、tdin);</p><p>  system("cls");}while(i!=123);</p><p><b>  }</b></p><p><b>  2.插入信息:</b></p><p><b>  相關代碼:</b></p>&

13、lt;p>  void insert(int count,struct stu st[])</p><p><b>  { </b></p><p><b>  char b;</b></p><p>  printf("\t\t\t學生信息添加\n");</p><p>

14、  for(;b!='n';)</p><p>  {if(n==30)</p><p>  {printf("滿員無法添加");</p><p><b>  break;};</b></p><p>  system("cls");</p><

15、p>  printf("\n\t\t\t請輸入學號:");</p><p>  scanf("%d",&st[n].num);</p><p>  printf("\n\t\t\t請輸入姓名:");</p><p>  scanf("%s",st[n].name);<

16、/p><p>  printf("\n\t\t\t請輸入性別:");</p><p>  scanf("%s",st[n].sex);</p><p>  printf("\n\t\t\t請輸入家庭住址:");</p><p>  scanf("%s",st[n].a

17、dd); </p><p><b>  n++;</b></p><p>  printf("\t\t\t是否繼續(xù)y\\n:");</p><p>  fflush(stdin);</p><p>  scanf("%c",&b);</p><p&g

18、t;  system("cls");</p><p>  fflush(stdin);</p><p>  while(b!='y')</p><p>  { if(b=='n')break;</p><p>  if(b!='y')printf("\n\t\t

19、\ty\\n");</p><p>  scanf("%c",&b);</p><p>  fflush(stdin);</p><p><b>  };</b></p><p><b>  }</b></p><p>  fflush(

20、stdin); </p><p>  printf("\t\t\t返回功能菜單……");</p><p><b>  }</b></p><p><b>  3.查詢信息</b></p><p><b>  相關代碼:</b></p><

21、;p>  void quer(struct stu st[])</p><p>  {int m=1;</p><p><b>  int t;</b></p><p><b>  int x;</b></p><p><b>  x=0;</b></p>

22、<p>  printf("\t\t\t\t請輸入要查詢的學號:");</p><p>  scanf("%d",&t);</p><p>  system("cls");</p><p>  for(x=0;x<=30;x++)</p><p>  if(

23、st[x].num==t)</p><p>  { head();</p><p>  printf("%d\t%s\t%s\t%s\n",st[x].num,st[x].name,st[x].sex,st[x].add);m=0;};</p><p>  if(m==1)printf("\t\t無查詢信息");</p

24、><p>  fflush(stdin); </p><p><b>  }</b></p><p><b>  4.顯示信息</b></p><p>  在主菜單上輸入3時進入,則顯示所有插入的信息。</p><p><b>  相關代碼:</

25、b></p><p>  void disp(int count,struct stu st[]) </p><p>  { int j=0;</p><p>  system("cls");</p><p><b>  head();</b><

26、;/p><p>  for(;j<n;j++)</p><p>  printf("%d\t%s\t%s\t%s\n",st[j].num,st[j].name,st[j].sex,st[j].add); </p><p><b>  }</b></p><p><b>  5.刪除信息&

27、lt;/b></p><p><b>  相關代碼:</b></p><p>  void del(struct stu st[])</p><p><b>  { </b></p><p><b>  int m=1;</b></p><p>&

28、lt;b>  int t;</b></p><p><b>  int x;</b></p><p><b>  int x1;</b></p><p><b>  x=0;</b></p><p>  printf("\t\t\t請輸入要刪除的學生

29、的學號:");</p><p>  scanf("%d",&t);</p><p>  for(x=0;x<=n&&m;x++)</p><p>  if(st[x].num==t)</p><p>  { for(x1=x;x1<=n;x1++)</p>&l

30、t;p>  st[x1]=st[x1+1];m=0;</p><p>  printf("已刪除該信息\n");</p><p><b>  n--;};</b></p><p>  if(m==1)printf("無需要刪除的信息\n");</p><p>  fflush

31、(stdin); </p><p><b>  }</b></p><p><b>  6.修改信息。</b></p><p><b>  相關代碼:</b></p><p>  void del(struct stu st[])</p><

32、;p><b>  { </b></p><p><b>  int m=1;</b></p><p><b>  int t;</b></p><p><b>  int x;</b></p><p><b>  int x1;</b

33、></p><p><b>  x=0;</b></p><p>  printf("\t\t\t請輸入要刪除的學生的學號:");</p><p>  scanf("%d",&t);</p><p>  for(x=0;x<=n&&m;x++)&

34、lt;/p><p>  if(st[x].num==t)</p><p>  { for(x1=x;x1<=n;x1++)</p><p>  st[x1]=st[x1+1];m=0;</p><p>  printf("已刪除該信息\n");</p><p><b>  n--;};

35、</b></p><p>  if(m==1)printf("無需要刪除的信息\n");</p><p>  fflush(stdin); </p><p><b>  }</b></p><p>  五.測試數(shù)據(jù)及運行結(jié)果</p><p>  (

36、1) 插入信息(打開文件)</p><p>  進入插入界面輸入圖上內(nèi)容。按n選擇退出。</p><p><b> ?。?)查找信息</b></p><p>  在選擇菜單上輸入2 彈出讓用戶輸入要查找的學號信息。在輸入后按enter 鍵會出現(xiàn)如下界面:</p><p><b> ?。?)顯示信息</b

37、></p><p>  在選擇菜單上輸入3 按回車鍵會顯示系統(tǒng)存儲的所有的信息。</p><p><b>  (4) 刪除信息</b></p><p>  在主菜單上輸入4后會有提示讓用戶輸入要刪除的學號信息,</p><p>  輸入后則會刪除該學號的相關所有信息。</p><p>  檢

38、查時進入 查看信息 功能,進入后則沒有顯示該學號的相關信息。</p><p><b>  (5) 修改信息</b></p><p>  修改后進入 查看信息 功能 ,打印出的數(shù)據(jù)中沒有修改前的信息。</p><p>  六.調(diào)試情況,設計技巧及體會</p><p>  好的方面,界面之間的轉(zhuǎn)換,盡量減少了系統(tǒng)的缺陷

39、,提示語句人性化,便于使用函數(shù)的調(diào)用及返回值,系統(tǒng)設置密碼可以保護用戶的信息不外泄。</p><p>  但是,程序可讀性不太高,注釋說明語句太少,程序做出來是給別人使用的,以后的學習中應該注意。</p><p>  七.附錄 (電子版源代碼)</p><p>  #include "stdio.h"</p><p>  

40、#include "string.h"</p><p>  #include "stdlib.h"</p><p>  #include "windows.h"</p><p>  void enter();</p><p>  int readdata();</p>

41、<p>  void stra();</p><p>  int save();</p><p>  void disp(int,struct stu st[]);</p><p>  void quer(struct stu st[]);</p><p>  void insert(int ,struct stu st[]);&l

42、t;/p><p>  void del(struct stu st[]);</p><p>  void modfix(struct stu st[]);</p><p>  void head();</p><p>  void restra();</p><p>  saveflag=0;</p><

43、;p>  struct stu</p><p>  { int num;</p><p>  char name[30];</p><p>  char sex[4];</p><p>  char add[40];</p><p><b>  };</b></p><

44、;p><b>  int n=0;</b></p><p>  struct stu st[30],*p=st;</p><p><b>  FILE *fp;</b></p><p>  int main()</p><p><b>  {</b></p>

45、<p><b>  enter();</b></p><p>  readdata();</p><p><b>  stra();</b></p><p><b>  save();</b></p><p>  fclose(fp);</p>&

46、lt;p><b>  return 0;</b></p><p><b>  }</b></p><p>  void enter()</p><p><b>  { </b></p><p><b>  int i;</b></p>

47、<p><b>  do</b></p><p>  {printf("***************學生信息管理系統(tǒng)中**************\n");</p><p>  printf("*******************系統(tǒng)初始化******************\n");</p>&l

48、t;p>  printf("初始密碼:");</p><p>  scanf("%d",&i);</p><p>  fflush(stdin);</p><p>  system("cls");</p><p>  }while(i!=123);</p>

49、<p><b>  }</b></p><p>  int readdata()</p><p><b>  {</b></p><p><b>  FILE *fp;</b></p><p>  if((fp=fopen("stdata.txt"

50、;,"r"))==NULL)</p><p><b>  {</b></p><p>  printf("數(shù)據(jù)文件無法打開,請檢查數(shù)據(jù)文件。\n");</p><p><b>  return 0;</b></p><p><b>  }</b

51、></p><p>  while(!feof(fp))</p><p><b>  {</b></p><p>  fscanf(fp,"%d\t%s\t%s\t%s\n",&st[n].num,st[n].name,st[n].sex,st[n].add);</p><p><

52、b>  n++;</b></p><p><b>  }</b></p><p>  fclose(fp);</p><p><b>  return 1;</b></p><p><b>  }</b></p><p>  int

53、save() //保存數(shù)據(jù)</p><p><b>  { </b></p><p><b>  int q;</b></p><p>  if((fp=fopen("stdata.txt","w"))==NULL)</p><p>  { printf(

54、"\t\t\t文件無法打開\n");</p><p><b>  return 0;</b></p><p><b>  };</b></p><p>  for(q=0;q<n;q++)</p><p>  fprintf(fp,"%d\t%s\t%s\t%s\

55、n",st[q].num,st[q].name,st[q].sex,st[q].add);</p><p>  fclose(fp);</p><p><b>  return 1;</b></p><p><b>  }</b></p><p>  void stra()</p&g

56、t;<p><b>  { int i;</b></p><p><b>  char c;</b></p><p><b>  do</b></p><p>  { for(i=0;i<5;i++)</p><p>  printf("\n&q

57、uot;);</p><p>  printf("\n");</p><p><b>  restra();</b></p><p>  printf("**************************************************\n");</p><p>

58、<b>  restra();</b></p><p>  printf("* 歡迎使用學生信息查詢系統(tǒng) *\n");</p><p><b>  restra();</b></p><p>  printf("* _________________

59、______________________________*\n");</p><p><b>  restra();</b></p><p>  printf("* 1.插入信息 2. 查詢信息 *\n");</p><p><b>  restra()

60、;</b></p><p>  printf("* 3.顯示信息 4. 刪除信息 *\n");</p><p><b>  restra();</b></p><p>  printf("* 5.修改信息 6. 退出系統(tǒng)

61、 *\n");</p><p><b>  restra();</b></p><p>  printf("* *\n");</p><p><b>  restra();</b><

62、/p><p>  printf("**************************************************\n");</p><p><b>  restra();</b></p><p>  printf("選擇使用的功能");</p><p>  sca

63、nf("%c",&c);</p><p>  fflush(stdin);</p><p><b>  switch(c)</b></p><p>  { case '1':restra();printf("功能1\n");</p><p>  i

64、nsert(n,p);</p><p><b>  save(p);</b></p><p>  getchar();break;</p><p>  case '2':restra();printf("功能2\n");</p><p><b>  quer(p);</

65、b></p><p>  getchar();break;</p><p>  case '3':restra();printf("功能3\n");</p><p>  disp(n,p); </p><p>  getchar();break;</p><p>  c

66、ase '4':restra();printf("功能4\n");</p><p><b>  del(p);</b></p><p><b>  save();</b></p><p>  getchar();break;</p><p>  case '

67、;5':restra();printf("功能5\n");</p><p>  modfix(p);</p><p><b>  save();</b></p><p>  getchar();break;</p><p>  case '6':printf("\n&

68、quot;);restra();printf("您選擇了退出本系統(tǒng)!\n謝謝使用您的使用!");</p><p>  break;};</p><p>  system("cls");</p><p>  }while(c!='6');</p><p>  if(c=='6&

69、#39;)</p><p><b>  { </b></p><p><b>  int k;</b></p><p>  printf("\n");</p><p>  restra(); </p><p>  if(saveflag==1)

70、 </p><p><b>  {</b></p><p>  fflush(stdin); </p><p>  printf("學生數(shù)據(jù)已經(jīng)改動,是否保存【y/n】:");</p><p>  k=getchar();</p><p>  fflush(stdin);

71、</p><p>  if(k=='y')</p><p><b>  save(st);</b></p><p><b>  }</b></p><p>  printf("\n\t\t數(shù)據(jù)保存成功!謝謝使用本系統(tǒng)?。?quot;);</p><p&g

72、t;<b>  }</b></p><p><b>  }</b></p><p>  void restra()</p><p><b>  { int i;</b></p><p>  for(i=0;i<=1;i++)</p><p>  p

73、rintf("\t");</p><p><b>  }</b></p><p>  void disp(int count,struct stu st[]) </p><p>  { int j=0;</p><p>  system("cls

74、");</p><p><b>  head();</b></p><p>  for(;j<n;j++)</p><p>  printf("%d\t%s\t%s\t%s\n",st[j].num,st[j].name,st[j].sex,st[j].add);

75、 </p><p><b>  }</b></p><p>  void quer(struct stu st[])</p><p>  {int m=1;</p><p><b>  int t;</b></p><p><b>  int x

76、;</b></p><p><b>  x=0;</b></p><p>  printf("\t\t\t\t請輸入要查詢的學號:");</p><p>  scanf("%d",&t);</p><p>  system("cls");&l

77、t;/p><p>  for(x=0;x<=30;x++)</p><p>  if(st[x].num==t)</p><p>  { head();</p><p>  printf("%d\t%s\t%s\t%s\n",st[x].num,st[x].name,st[x].sex,st[x].add);m=0;}

78、;</p><p>  if(m==1)printf("\t\t無查詢信息");</p><p>  fflush(stdin); </p><p><b>  }</b></p><p>  void insert(int count,struct stu st[])</p&

79、gt;<p><b>  { </b></p><p><b>  char b;</b></p><p>  printf("\t\t\t學生信息添加\n");</p><p>  for(;b!='n';)</p><p>  {if(n==30

80、)</p><p>  {printf("滿員無法添加");</p><p><b>  break;};</b></p><p>  system("cls");</p><p>  printf("\n\t\t\t請輸入學號:");</p>&

81、lt;p>  scanf("%d",&st[n].num);</p><p>  printf("\n\t\t\t請輸入姓名:");</p><p>  scanf("%s",st[n].name);</p><p>  printf("\n\t\t\t請輸入性別:");&

82、lt;/p><p>  scanf("%s",st[n].sex);</p><p>  printf("\n\t\t\t請輸入家庭住址:");</p><p>  scanf("%s",st[n].add); </p><p><b>  n++;</b>&l

83、t;/p><p>  saveflag=1;</p><p>  printf("\t\t\t是否繼續(xù)y\\n:");</p><p>  fflush(stdin);</p><p>  scanf("%c",&b);</p><p>  system("cls&

84、quot;);</p><p>  fflush(stdin);</p><p>  while(b!='y')</p><p>  { if(b=='n')break;</p><p>  if(b!='y')printf("\n\t\t\ty\\n");</p&

85、gt;<p>  scanf("%c",&b);</p><p>  fflush(stdin);</p><p><b>  };</b></p><p><b>  }</b></p><p>  fflush(stdin); </p>

86、<p>  printf("\t\t\t返回功能菜單……");</p><p><b>  }</b></p><p>  void del(struct stu st[])</p><p><b>  { </b></p><p><b>  int m=1

87、;</b></p><p><b>  int t;</b></p><p><b>  int x;</b></p><p><b>  int x1;</b></p><p><b>  x=0;</b></p><p&

88、gt;  printf("\t\t\t請輸入要刪除的學生的學號:");</p><p>  scanf("%d",&t);</p><p>  for(x=0;x<=n&&m;x++)</p><p>  if(st[x].num==t)</p><p>  { for(

89、x1=x;x1<=n;x1++)</p><p>  st[x1]=st[x1+1];m=0;</p><p>  printf("已刪除該信息\n");</p><p><b>  n--;};</b></p><p>  if(m==1)printf("無需要刪除的信息\n&quo

90、t;);</p><p>  fflush(stdin); </p><p><b>  }</b></p><p>  void modfix(struct stu st[])</p><p><b>  { int f;</b></p><p><

91、;b>  int xh;</b></p><p><b>  int m1=1;</b></p><p>  system("cls");</p><p>  printf("\t\t輸入需要修改的學生信息的學號:");</p><p>  scanf("

92、;%d",&xh);</p><p>  for(f=0;f<=n&&m1;f++)</p><p>  if(st[f].num==xh)</p><p>  { printf("\n\t\t\t請輸入新學號:");</p><p>  scanf("%d"

93、,&st[f].num);</p><p>  printf("\n\t\t\t請輸入新姓名:");</p><p>  scanf("%s",st[f].name);</p><p>  printf("\n\t\t\t請輸入新性別:");</p><p>  scanf(

94、"%s",st[f].sex);</p><p>  printf("\n\t\t\t請輸入新家庭住址:");</p><p>  scanf("%s",st[f].add); </p><p><b>  m1=0;</b></p><p>  printf(

95、"\t\t\t是否繼續(xù)y\\n:");</p><p>  fflush(stdin);</p><p><b>  };</b></p><p>  if(m1==1)printf("無需要修改的信息\n");</p><p>  fflush(stdin);

96、</p><p><b>  }</b></p><p>  void head()</p><p><b>  { </b></p><p>  printf("學號\t姓名\t性別\t家庭住址\n");</p><p><b>  }<

溫馨提示

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

評論

0/150

提交評論