學生成績管理系統

2021-04-13 04:28:28 字數 3607 閱讀 2876

#include

#include

#include

#include

#include

#include

#include

#include

#define null 0

#define esc 0x001b  /* 退出 */

#define  f1  0x3b00  /* 檢視幫助資訊,呼叫helpmassage()函式 */

#define  f2  0x3c00  /*輸入學生成績*/

#define  f3  0x3d00 /*按學號查詢*/

#define  f4  0x3e00  /*按姓名查詢*/

#define  f5  0x3f00  /*列出所有

學生成績*/

#define  f6  0x4000 /*統計*/

struct stutype  /*定義結構體變數*/

;/*-------------2-------------*/

int jy_no(char *stu_num,file *fp)    /*檢驗學號的正確性*/

else p++;      /*指標加1*/

}if(strlen(stu_num)!=10)     /*若學號長度不為10,則返回重新輸入*/

if(getchar()!='/n')      /*若學號後面的字元不是回車符,則學號長度大於10*/

while(getchar()!='/n');   /*用getchar接收多餘的字元*/

return 0;      

} else}}

return 1;

}/*-------------3-------------*/

int jy_no2(char *stu_num)   /*檢驗學號*/

while(*p!='/0')    /*學號必須用數字,若包含有字母,或其它字元則返回假值重新輸入*/

else p++;    /*指標加1*/

}if(getchar()!='/n')   /*檢驗學號長度是否大於10,並把多餘的字元去掉*/

while(getchar()!='/n');

return 0;      

} return 1;

}/*-------------4-------------*/

int jy_xm(char *stu_xm)    /*檢驗姓名*/

else p++;     /*使指標加1,指向下一

漢字*/}

if(getchar()!='/n')    /*姓名長度不得大於5個*/

while(getchar()!='/n');

return 0;      

} return 1;     /*字串全為漢字返回真*/

/*-------------5-------------*/

int jy_cj(float stu_cj)    /*學生成績只能在0~100之間*/

return 1;

}/*-------------6-------------*/

void creatfile()     /*輸入檔案*/

;   /*對stu0先賦值*/

fp=fopen("stu.dat","wb+");    /*開啟或建立乙個二進位制檔案,開啟時將原來的內容刪除*/

if(fp==null)

else

while(!jy_no(stu.no,fp));

if(strcmp(stu.no,"#")==0)break;

dowhile(!jy_xm(stu.xm));

dowhile(!jy_cj(stu.cj[0]));

dowhile(!jy_cj(stu.cj[1]));

dowhile(!jy_cj(stu.cj[2]));

dowhile(!jy_cj(stu.cj[3]));

fwrite(&stu,sizeof(struct stutype),1,fp); /*寫檔案*/}}

fclose(fp);      /*關閉檔案*/

/*-------------7-------------*/

void search_xuehao()       /*按學號查詢*/

else

while(!jy_no2(stu.no));

if(strcmp(stu.no,"#")==0)break;         /*若輸入「#」則結束迴圈*/

flag=0;

rewind(fp);

while(fread(&stud,sizeof(struct stutype),1,fp))      /*檢查檔案指標結束*/

}if(flag==0)puts("/t/t/t無此學號!");

}while(strcmp(stu.no,"#")!=0);

}  

fclose(fp);        /*關閉檔案*/

}/*-------------8-------------*/

void search_xingming()       /*按姓名查詢*/

else

while(!jy_xm(stu.xm));

rewind(fp);      /*檔案指標指向頭*/

while(fread(&stud,sizeof(struct stutype),1,fp))

}if(flag==0)puts("/n/t/t/t無此學生!");

puts("/t/t/t是否繼續(y--繼續,其他返回)?");

}while(getch()=='y');

}fclose(fp);  

/* puts("/t/t/t請按任意鍵繼續...");*/

/* getch();*/

/*-------------9-------------*/

int listfile(void)       /*輸出檔案,列出所有學生成績*/

else}}

fclose(fp);        /*關閉檔案*/

printf("/t/t/t請按任意鍵繼續...");

getch();

}/*-------------10-------------*/

void statistics()       /*

統計及格和優秀人數*/

,good[4]=;     /*rec--記錄個數,即人數,pass--及格人數,good--優秀人數*/

float highest[4]=,score[4]=;     /*highest--最高分,score--總分*/

struct stutype stu;

fp=fopen("stu.dat","rb");

if(fp==null)

else

/*-------------12-------------*/

int getkey(void)     /*此函式返回乙個按鍵的數值*/

return key;     /*返回按鍵*/

} /*-------------13-------------*/

void main()

clrscr();     /*每執行完一項功能後,自動清屏*/}} 

學生成績管理系統

include include include define n 50 定義符號常量,代表學生人數最大值 int count 0 全域性變數,用於記錄陣列的當前位置 struct student 定義結構體型別,代表學生資訊 void input struct student arr 函式宣告,輸入...

學生成績管理系統

這是進入大學以來,第一次做的c語言課程設計,覺得挺有意義,把 貼上來,曬一下!學生成績管理系統 教師,管理員密碼 輸入學生的基本資訊 輸出學生的基本資訊 查詢學生的基本資訊 學生成績分析 排序 統計 退出 include include include include include include...

學生成績管理系統

剛剛學習完c語言做的乙個簡單專案,當時還沒有 分層的概念,做了好多天,改了好多錯誤 雖然完成了基本功能,但是還不夠完善,並且還有很多的不足,後期還要進行修改。學生管理系統源 include include include define len sizeof struct teacher struct...