求C语言课程设计(教务信息管理系统) 求(C语言课程设计)学生成绩管理系统

作者&投稿:登亮 (若有异议请与网页底部的电邮联系)
/*-------------1-------------*/
#include<bios.h>
#include<dos.h> /*头文件*/
#include<conio.h>
#include<ctype.h>
#include<process.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>

#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 /*定义结构体变量*/
{
char NO[11]; /*学号长度为10*/
char XM[10];
char AGE[2]; /*年龄长度为2*/
float CJ[4]; /*包含4门成绩*/
};

/*-------------2-------------*/
int JY_NO(char *stu_num,FILE *fp) /*检验学号的正确性*/
{ struct stuType stud;
int NO;
char *p=stu_num;
if(strcmp(stu_num,"#")==0) return 1; /*若输入"#"返回真值,不再循环输入*/
while(*p!='\0') /*学号必须是数字,否则返回重新输入*/
{ NO=(int)*p;
if(NO<48||NO>57)
{ puts("\t\tUndefined SN!Please input again!\n");/*非法学号!请重新输入!*/
return 0;
}
else p++; /*指针加1*/
}
if(strlen(stu_num)!=10) /*若学号长度不为10,则返回重新输入*/
{ puts("\t\tLength of SN Error!\n");/*学号长度不对*/
return 0;
}
if(getchar()!='\n') /*若学号后面的字符不是回车符,则学号长度大于10*/
{ printf("\t\tThe length of SN should more than 10!Please input again!\n");/*学号长度大于10个,请重新输入*/
do{}while(getchar()!='\n'); /*用getchar接收多余的字符*/
return 0;
}

else
{
rewind(fp); /*使文件指针指向头*/
while(!feof(fp)) /*若文件指针未到结尾,就继续执行下面的循环,feof遇到文件结束符返回非零值,否则返回0*/
{ fread(&stud,sizeof(struct stuType),1,fp); /*读取一定长度的数据*/
if(strcmp(stu_num,stud.NO)==0) /*学号的唯一性*/
{ printf("\t\t Repeat SN,Please input again!\n");/*学号重复!请重新输入*/
printf("\t\tThe Record of this student:\n");/*该学生成绩如下*/
printf("\t\tChinese:%.1f\n",stud.CJ[0]);/*语文*/
printf("\t\tMath:%.1f\n",stud.CJ[1]);/*数学*/
printf("\t\tEnglish:%.1f\n",stud.CJ[2]);/*英语*/
printf("\t\tTotal:%.1f\n",stud.CJ[3]);/*总评*/
return 0;
}
}
}
return 1;

}
/*-------------3-------------*/
int JY_NO2(char *stu_num) /*检验学号*/
{ int NO;
char *p=stu_num;
if(strcmp(stu_num,"#")==0)return 1; /*若输入“#”,则返回真值结束*/
if(strlen(stu_num)!=10) /*学号长度不为10*/
{ puts("\t\tLength of SN Error!\n");/*学号长度不对*/
return 0;
}
while(*p!='\0') /*学号必须用数字,若包含有字母,或其它字符则返回假值重新输入*/
{ NO=(int)*p;
if(NO<48||NO>57)
{ puts("\t\tUndefined SN!Please input again!\n");/*非法学号!请重新输入*/
return 0;
}
else p++; /*指针加1*/
}
if(getchar()!='\n') /*检验学号长度是否大于10,并把多余的字符去掉*/
{ printf("\t\tThe length of SN should more than 10!Please input again!\n");/*学号长度大于10个,请重新输入*/
do{}while(getchar()!='\n');
return 0;
}
return 1;
}

/*-------------4-------------*/
int JY_XM(char *stu_XM) /*检验姓名*/
{ int PD;
char *p;
p=stu_XM;
while(*p!='\0') /*姓名只能用英文*/
{
PD=(int)*p;
if(PD<0)
{ puts("\t\tName should use English, Please input again!\n");/*姓名只能用英文请重新输入*/
return 0;
}
else p++; /*使指针加1,指向下一汉字*/
}
if(getchar()!='\n') /*姓名长度不得大于5个*/
{ printf("\t\tThe length of Name is more than 5, Please input again!\n");/*姓名长度大于5个请重新输入*/
do{}while(getchar()!='\n');
return 0;
}
return 1; /*字符串全为汉字返回真*/

}

/*-------------5-------------*/
int JY_AGE(float stu_AGE) /*年龄只能在0~100之间*/
{
if(stu_AGE<0||stu_AGE>100)
{ printf("\t\tInput Error! Record should between 0~100!\n");/*输入错误,成绩只能在0~100之间*/
return 0;
}
return 1;
}

/*-------------6-------------*/
int JY_CJ(float stu_CJ) /*学生成绩只能在0~100之间*/
{
if(stu_CJ<0||stu_CJ>100)
{ printf("\t\tInput Error! Record should between 0~100!\n");/*输入错误,成绩只能在0~100之间*/
return 0;
}
return 1;
}

/*-------------7-------------*/
void CreatFile() /*输入文件*/
{ FILE *fp;
struct stuType stu,stu0={"","",}; /*对stu0xianfuzhi*/
fp=fopen("stu.dat","wb+"); /*打开或创建一个二进制文件,打开时将原来的内容删除*/
if(fp==NULL)
{ printf("\t\tFile opens Error!\n\t\t\tPress Anykey back...");/*文件打开失败,按任意键返回*/
getch();
return;
}
else
{ while(1)
{ stu=stu0;
do{ printf("\n\t\tPlease input SN:"); /*输入学号并检验其正确性*/
scanf("%10s",stu.NO);
}while(!JY_NO(stu.NO,fp));
if(strcmp(stu.NO,"#")==0)break;
do{ printf("\n\t\tPlease input Name:"); /*输入姓名并检验其正确性*/
scanf("%10s",stu.XM);
}while(!JY_XM(stu.XM));
do{ printf("\n\t\tPlease input age:"); /*输入年龄绩并检验其正确性*/
scanf("%f",&stu.AGE);
}while(!JY_AGE(stu.AGE[0]));
do{ printf("\n\t\tPlease input record of Chinese:"); /*输入成绩并检验其正确性*/
scanf("%f",&stu.CJ[0]);
}while(!JY_CJ(stu.CJ[0]));
do{ printf("\n\t\tPlease input record of Math:"); /*同上*/
scanf("%f",&stu.CJ[1]);
}while(!JY_CJ(stu.CJ[1]));
do{ printf("\n\t\tPlease input record of English:");
scanf("%f",&stu.CJ[2]);
}while(!JY_CJ(stu.CJ[2]));
do{ printf("\n\t\tPlease input record of Total:");
scanf("%f",&stu.CJ[3]);
}while(!JY_CJ(stu.CJ[3]));
fwrite(&stu,sizeof(struct stuType),1,fp); /*写文件*/
}

}
fclose(fp); /*关闭文件*/

}

/*-------------8-------------*/
void Search_Xuehao() /*按学号查询*/
{ FILE *fp;
int flag;
struct stuType stu,stud;
fp=fopen("stu.dat","rb");
if(fp==NULL) /*若文件打不开则输出下面的信息*/
{ printf("\t\tFile opens Error!\n\t\t\tPress Anykey back...");
getch();
return;
}
else
{ do{ puts("\n\t\tPress\"#\" or search");
do{ printf("\t\tPlease input the SN what you want:");
scanf("%10s",stu.NO);
}while(!JY_NO2(stu.NO));
if(strcmp(stu.NO,"#")==0)break; /*若输入“#”则结束循环*/
flag=0;
rewind(fp);
while(fread(&stud,sizeof(struct stuType),1,fp)) /*检查文件指针结束*/
{ if(strcmp(stu.NO,stud.NO)==0) /*比较学号*/
{ puts("\t\tThe Record of this student:");
printf("\t\tSN:%s\n",stud.NO);
printf("\t\tName:%s\n",stud.XM);
printf("\t\tAGE:%.1f\n",stud.AGE[0]);
printf("\t\tChinese:%.1f\n",stud.CJ[0]);
printf("\t\tMath:%.1f\n",stud.CJ[1]);
printf("\t\tEnglish:%.1f\n",stud.CJ[2]);
printf("\t\tTotal:%.1f\n",stud.CJ[3]);
flag=1; /*记录学号是否查到*/
}
}
if(flag==0)puts("\t\tUndefined SN");
}while(strcmp(stu.NO,"#")!=0);

}
fclose(fp); /*关闭文件*/

}

/*-------------9-------------*/
void Search_Xingming() /*按姓名查找*/
{ FILE *fp;
int flag=0;
struct stuType stu,stud;
fp=fopen("stu.dat","rb");
if(fp==NULL)
{ printf("\t\tFile opens Error!\n\t\tPress Anykey back...");
getch();
return;
}
else
{ do{
do{ printf("\t\tPlease input the Name of the Student what you want:");
scanf("%10s",stu.XM);
}while(!JY_XM(stu.XM));
rewind(fp); /*文件指针指向头*/
while(fread(&stud,sizeof(struct stuType),1,fp))
{ if(strcmp(stu.XM,stud.XM)==0) /*比较姓名是否相同*/
{ puts("\t\tThe name of the Student is:");
printf("\t\tSN:%s\n",stud.NO);
printf("\t\tName:%s\n",stud.XM);
printf("\t\tAGE:%.1f\n",stud.AGE[0]);
printf("\t\tChinese:%.1f\n",stud.CJ[0]);
printf("\t\tMath:%.1f\n",stud.CJ[1]);
printf("\t\tEnglish:%.1f\n",stud.CJ[2]);
printf("\t\tTotal:%.1f\n",stud.CJ[3]);
flag=1; /*记录姓名是否被查到*/
}
}
if(flag==0)puts("\n\t\tUndefined Name!");
puts("\t\tContinue?(y--yes,Else key back)?");
}while(getch()=='y');
}
fclose(fp);
/* puts("\t\tPress Anykey to continue...");*/
/* getch();*/

}

/*-------------10-------------*/
int ListFile(void) /*输出文件,列出所有学生成绩*/
{ FILE *fp;
int REC=0; /*记录学生人数*/
struct stuType stu;
fp=fopen("stu.dat","rb");
if(fp==NULL)
{ printf("\t\tFile opens Error!\n\t\tPress Anykey back...");
getch();
return 1;
}
else{ printf("\t\tRecords of the Students:\n");
printf("\t\tSN\t\tName\tChinese\tMath\tEnglish\tTotal\n");
rewind(fp);
while(fread(&stu,sizeof(struct stuType),1,fp))
{ /*每读取一个长度的数据就输出*/
printf("\t\t%s",stu.NO);
printf("\t%s",stu.XM);
printf("\t%.1f",stu.AGE);
printf("\t%.1f",stu.CJ[0]);
printf("\t%.1f",stu.CJ[1]);
printf("\t%.1f",stu.CJ[2]);
printf("\t%.1f",stu.CJ[3]);
printf("\n");
REC++;
if(REC%20==0) /*20个学生成绩,停一下*/
{ printf("\t\tPress Anykey to continue...\n");
getch();
}
}
}
fclose(fp); /*关闭文件*/
printf("\t\tContinue...");
getch();

}

/*-------------11-------------*/
void Statistics() /*统计及格和优秀人数*/
{ FILE *fp;
int REC=0,unpass[4]={0},good[4]={0}; /*REC--记录个数,即人数,unpass--重修人数,good--优秀人数*/
float highest[4]={0},score[4]={0}; /*highest--最高分,score--总分*/

struct stuType stu;
fp=fopen("stu.dat","rb");
if(fp==NULL)
{ printf("\t\tFile opens Error!\n\t\tPress Anykey back...");
getch();
return;
}
else { rewind(fp);
while(fread(&stu,sizeof(struct stuType),1,fp))
{ REC++;
score[0]=score[0]+stu.CJ[0]; /*语文*/
if(stu.CJ[0]<=60)unpass[0]++;
if(stu.CJ[0]>=80)good[0]++;
if(highest[0]<stu.CJ[0])highest[0]=stu.CJ[0];
score[1]=score[1]+stu.CJ[1]; /*数学*/
if(stu.CJ[1]<=60)unpass[1]++;
if(stu.CJ[1]>=80)good[1]++;
if(highest[1]<stu.CJ[1])highest[1]=stu.CJ[1];
score[2]=score[2]+stu.CJ[2]; /*英语*/
if(stu.CJ[2]<=60)unpass[2]++;
if(stu.CJ[2]>=80)good[2]++;
if(highest[2]<stu.CJ[2])highest[2]=stu.CJ[2];
score[3]=score[3]+stu.CJ[3]; /*总评*/
if(stu.CJ[3]<=60)unpass[3]++;
if(stu.CJ[3]<=80)good[3]++;
if(highest[3]<stu.CJ[3])highest[3]=stu.CJ[3];
}
if(REC==0) /*可以防止记录为0是REC作除数而造成的错误*/
{ printf("\t\tYou did't input the Name!Press Anykey back...");
getch();
return;
}
else{
printf("\t Chinese\t Math\t English\tTotal\n"); /*输出统计信息*/
printf("\tAverage: %.1f\t %.1f\t %.1f\t\t%.1f\n",score[0]/REC,score[1]/REC,score[2]/REC,score[3]/REC);
printf("\tTop record: %.1f\t %.1f\t %.1f\t\t%.1f\n",highest[0],highest[1],highest[2],highest[3]);
printf("\tNumber of good students: %d\t\t %d\t %d\t\t %d\n",good[0],good[1],good[2],good[3]);
printf("\tNumber of unpassed students:%d\t\t %d\t %d\t\t %d\n",unpass[0],unpass[1],unpass[2],unpass[3]);
}
}
fclose(fp);
printf("\n\t\t\tPress Anykey to continue...");
getch();

}

/*-------------12-------------*/
void HelpMessage()
{ clrscr();
printf("\n\n\n\n\n chi xi tong shi lao shi suo bu zhi zuoye bianzhi ercheng,gai xitong juyou cunchu xuesheng shuju,an xuehao,xingming chaxun,liechu xuesheng chengji he tongjigongneng.\n \n shiyongfangfa:xitong shulu shuju hou,jiangzai dangqian muluzhong jianli yige mingwei stu.dat wenjian,yongyubaocun shulu de shuju.xuehao shulu zhineng yong shuzi shulu qie xuehao zhineng shi10wei.xingming shulu fuhe zhongguoren de xingming,zhineng yong zhongwen pinying,qie zuichangwei5 ge hanzhi.\n chi chenxu zai Turbo C2.0xia yunxing tongguo \n\n ");
getch();
}

/*-------------13-------------*/
int GetKey(void) /*此函数返回一个按键的数值*/
{ int key;
key=bioskey(0); /*bioskey为调用BIOS键盘接口*/
if(key<<8) /*位移*/
{
key=key&0x00ff;

}
return key; /*返回按键*/
}

/*-------------14-------------*/
void main()
{ int key;
struct date d; /*定义时间结构体*/
getdate(&d); /*读取系统日期并把它放到结构体d中*/
clrscr(); /*清除屏幕*/
printf("\n\n\n\n\n");
printf("\t ========================================================\n"); /*版本信息*/
printf("\n");
printf("\t\t The System of Students Records Management 1.0 \n");
printf("\n");
printf("\n");
printf("\t\t Builder: XG042-WZM YS HYF WQ \n");
printf("\t\t Teacher:Song Zheyuan\n");
printf("\t\t Time:2005\\7\\5 \n");
printf("\n");
printf("\t ========================================================\n");
printf("\t\t\tPress Anykey to continue...");
/*while(!kbhit());*/
getch(); /*从键盘读取一个字符,但不显示于屏幕*/
system("cls"); /*调用DOS的清屏函数,TC中可用clrscr代替*/
while(1) /*主菜单*/
{
printf("\n\n\n\n\n");
printf("\t **************************************************\n");
printf("\t **\t **\n");
printf("\t **\tF1 --Help **\n");
printf("\t **\t **\n");
printf("\t **\tF2 --Data Input & Save **\n");
printf("\t **\t **\n");
printf("\t **\tF3 --Search by SN **\n");
printf("\t **\t **\n");
printf("\t **\tF4 --Search by Name **\n");
printf("\t **\t **\n");
printf("\t **\tF5 --Contents Input **\n");
printf("\t **\t **\n");
printf("\t **\tF6 --Count Students Number(Passed&Good) **\n");
printf("\t **\t **\n");
printf("\t **\tESC--Quit the System **\n");
printf("\t **\t **\n");
printf("\t **************************************************\n");
printf("\n\t Please select...\t\t%d\\%d\\%d\n\n",d.da_year,d.da_mon,d.da_day); /*提示信息,并显示当前系统日期*/
key=GetKey(); /*调用自定义函数,读取一个键*/
switch(key)
{
case F1: HelpMessage(); break;
case F2: CreatFile(); break;

case F3: Search_Xuehao(); break;
case F4: Search_Xingming();break;
case F5: ListFile(); break;
case F6: Statistics(); break;
case ESC:exit(1); break;
/*default: puts("\t\t\tWrong SN input!");
printf("\t\t\tPress Anykey back...");
getch();*/
}
clrscr(); /*每执行完一项功能后,自动清屏*/
}

}

求做C语言课程设计 学生信息管理系统设计?~

OK学生信息管理系统设计原创,我帮你提供,包查重!

#include "stdio.h"
#include "conio.h"
#include "string.h"
#include "stdlib.h"
#define CMD_START printf("

######### Start a command #########
");
/* 用来标记一个命令执行的开始 */
#define CMD_END printf( "
######### End a command #########

");
/* 用来标记一个命令执行的结束
,这两个语句是为了提供更好的用户界面而写的 */
#define DATA_FILE "data.dat"
/* 这是 数据文件名 */
#define TEMP_FILE "temp.dat"
/* 这是一个临时的文件的名字,在删除记录的函数中使用的,
详细内容参考 Delete() 函数 */
typedef struct tagStudent
{
char ID[30];/* 学号 */
char Name[30];/* 姓名 */
char Class[255];/* 班级 */
char Sex;/* 性别 ,值为 F 或 f 或 M 或 m */
int Math;/* 数学成绩 */
int English;/* 英语成绩 */
int Compute;/* 计算机成绩 */
int Philosophy;/* 哲学成绩 */
int PE;/* 体育成绩 */
} Student;
/* 这是学生信息结构体 */
int ShowMenu();/* 在屏幕上打印 主菜单

的函数,它的返回值为 所选
菜单的 项目编号 */
int ReadData(FILE *, Student *);/* 从一个
打开的数据文件中读取
记录的函数,错误返回 0 */
int WriteData(FILE *, Student *);/* 向一个数据文件中 写入
记录的函数,错误返回 0 */
void Output_Rec(Student *);/* 在屏幕上 打印 一条记录 */
void Input_Rec(Student *);/* 让用户输入 记录的 各个项目的
值,在添加记录时用到了 */
void CopyRec(Student *, Student *);/* 复制一条记录 到
另一个记录中 */
/* 题目中要求的函数 */
void Print();/* 实现查看数据文件内容的函数 */
void Add();/* 添加记录的函数 */
void Delete();/* 删除记录的函数 */
void Statistics();/* 对数据进行统计分析的函数 */
void Find(int);/* 实现查找功能的函数,参数决定
是按 ID 查找 还是按 Name 查找 */
int quit;/* 一个全局变量,在下面的 main()
函数中,用来决定何时退出主循环
*/
main()
{
int cmd;/* 用户所选的 菜单 项目 的标号 */
quit = 0;/* 初始化 为 不退出 */
/* 这是程序的主循环,每次都将 主菜单打印出来,
供用户选择相应的 序号 来执行相应的功能 */
while (!quit)
{
cmd = ShowMenu();/* 显示
主菜单,并返回用户所选择的
菜单项 的 编号 */
CMD_START/* 在屏幕上打印一行分隔符,告诉用户这是一个子功能的开始
*/
switch (cmd)/* 用多项分支 根据 用户的选择
调用 相应的函数 */
{
case 1:
Print();
break;/* 用户选择 1 号菜单,程序执行
查看的数据文件的函数 */
case 2:
Add();
break;/* 用户选择 2 号菜单,程序执行
添加记录的函数 */
case 3:
Delete();
break;/* 用户选择 3 号菜单,程序执行
删除记录的函数 */
case 4:
Statistics();
break;/* 用户选择 4 号菜单,程序执行
统计数据的函数 */
case 5:
Find(5);
break;/* Find_ID ,5 号菜单执行 按
ID(学号)查找的功能 */
case 6:
Find(6);
break;/* Find_Name,6 号菜单执行 按
Name(姓名)查找的功能 */
case 7:
quit = 1;/* 用户选择了退出菜单 */
printf
(" Thank you for your using .

Happy everyday !!

Bye Bye ....
");
break;
default:
printf(" Please Input a number between1to7.
");
/* 用户所输入的 序号不在所处理的范围内 */
}
CMD_END/* 打印一行分隔符,告诉用户
他所选择的菜单的功能已经执行完毕
*/
if (quit != 1)/* 检查用户是否 要求 退出 */
{
printf(" Press any key to Return Main Menu ....
");
getch();/* 用 一个 无回显 的 字符输入函数
来实现暂停执行,按 任意键
继续的功能 */
}
}
}

int ShowMenu()
{
int cmd = 0;/* 保存用户的选择 */
/* 定义 程序所支持的菜单项目 */
char Menu_SeeData[] = "1 .View the Records in the data file
";/* 查看数据文件
*/
char Menu_Add[] = "2 .Add New Record
";/* 添加记录 */
char Menu_Delete[] = "3 .Delete an old Record
";/* 删除记录 */
char Menu_Statistics[] = "4 .Make a Statistics
";/* 统计分析 */
char Menu_Find_ID[] = "5 .Find a Record from the ID
";/* 按
学号(ID)
查找 */
char Menu_Find_Name[] = "6 .Find a Record from the Name
";/* 按
姓名(Name)
查找 */
char Menu_Quit[] = "7 .Quit
";/* 退出 */
/* 在屏幕上打印 主菜单 */
printf("

############ Main Menu ###############
");
printf("##############################################

");
printf(Menu_SeeData);
printf(Menu_Add);
printf(Menu_Delete);
printf(Menu_Statistics);
printf(Menu_Find_ID);
printf(Menu_Find_Name);
printf(Menu_Quit);
printf("
##############################################");
printf("

Input the index of your choice : ");
scanf("%d", &cmd);/* 接受用户 选择 */
printf("
");
return cmd;/* 返回用户的输入,交给主循环处理
*/
}

void Print()/* 打印 数据文件的 记录内容 */
{
FILE *fp = NULL;/* 文件指针 */
Student rec;/* 存放从文件中读取的记录 */
int i = 0;/* 实现 计数 和 分屏打印的功能 */
fp = fopen(DATA_FILE, "rb");/* 以 二进制读 方式
打开数据文件 */
if (fp == NULL)/* 打开文件出错 */
{
printf(" Can not open the data file : %s
", DATA_FILE);
return;
}
while (ReadData(fp, &rec))/* ReadData()
函数出错或到文件末尾时返回
0,可以做循环条件 */
{
Output_Rec(&rec);/* 正确读取,将记录输出 */
printf(" ------------------------------------------");
/* 打印一行分隔符,营造好的用户界面 */
i ;/* 计数器 加一 */
if (i % 4 == 0)/* 显示 4 个暂停一下 */
{
printf("
Press any key to continue ...
");
getch();
}
}
printf("
The current data file have%drecord .
", i);
fclose(fp);/* 关闭文件 */
}

void Add()/* 添加记录 */
{
Student rec;
FILE *fp = NULL;
Input_Rec(&rec);/* 让用户输入新记录的各项内容 */
fp = fopen(DATA_FILE, "ab");/* 以 添加 方式打开数据文件 */
if (fp == NULL)
{
printf(" Can not open the data file to write into ...
");
return;
}
if (WriteData(fp, &rec) == 1)/* 将 新记录 写入文件,并检查
是否正确写入 */
printf("

Add New Record Success

");
else
printf("

Failed to Write New Record into the data file
");
fclose(fp);
}

void Delete()/* 删除记录 */
{
Student rec;
FILE *fpr, *fpw;/* 两个文件指针,分别用于 读 和
写 */
char buf[30];/* 接受 用户输入的 ID 缓冲区 */
char cmd[255];/* 执行的系统命令 */
int del_count;/* 实际 删除的 记录数目 */
del_count = 0;
printf("
Please type the ID of the record you want me to delete .");
printf("
The ID : ");/* 提示用户 输入 */
scanf("%s", buf);
fpr = fopen(DATA_FILE, "rb");/* 从
原来的记录文件中读取数据,跳过将要删除的记录
*/
if (fpr == NULL)
{
printf(" Can not open the data file to read record ...
");
return;
}
fpw = fopen(TEMP_FILE, "wb");/* 打开一个 临时文件
保存不删除的记录 */
if (fpw == NULL)
{
printf(" Can not open the data file to write into ...
");
return;
}
while (ReadData(fpr, &rec))/* 读取 要保留的记录 */
{
if (strcmp(rec.ID, buf) != 0)
{
WriteData(fpw, &rec);/* 写入临时文件 ,然后删除
原数据文件,
再将临时文件该名为原数据文件的名字
*/
}
else
{
del_count ;/* 跳过的记录数目,即删除的数目 */
}
}
fclose(fpr);
fclose(fpw);
strcpy(cmd, "del ");/* 构造命令串,用 system() 函数执行
*/
strcat(cmd, DATA_FILE);
system(cmd);
rename(TEMP_FILE, DATA_FILE);/* 直接调用 C
语言的改名函数将临时文件改名为数据文件的名字
*/
printf("
I have delete%drecord .
", del_count);
}

void Statistics()/* 统计分析函数 */
{
int i50, i60, i70, i80, i90;/* 平均分小于60
,60-69,70-79,80-89,>=90
的分数段的学生数目 */
float avg;/* 平均分 */
int sum, sum_high, sum_low;/* 总分,总分最高分,总分最低分 */
Student stu_high, stu_low;/* 总分最高和最低 学生的信息 */
Student stu_math_high, stu_english_high;/* 各科
最高分的学生记录副本
*/
Student stu_compute_high, stu_philosophy_high, stu_PE_high;
Student stu_math_low, stu_english_low;/* 各科最低的学生记录副本
*/
Student stu_compute_low, stu_philosophy_low, stu_PE_low;
FILE *fp;
Student rec;
int count;/* 一个计数器,用于判断是否第一次读取数据
*/
count = sum = sum_high = sum_low = i50 = i60 = i60 = i70 = i80 = i90 = 0;
fp = NULL;/* 对 数据初始化 */
fp = fopen(DATA_FILE, "rb");
if (fp == NULL)
{
printf("
Can not open the data file to read ...
");
return;
}
while (ReadData(fp, &rec))/* 读取数据 */
{
count ;/* 计数器 加一 */
sum = rec.Math rec.English rec.Compute rec.PE rec.Philosophy;/* 求和
*/
/* average */
avg = ((float)sum) / 5;/* 平均分 */
/* 下面对各个分数段进行统计 */
if (avg < 60)
i50 ;
else if (avg < 70)
i60 ;
else if (avg < 80)
i70 ;
else if (avg < 90)
i80 ;
else
i90 ;
/* highest and loeest */
if (count <= 1)/* 第一次读取,执行初始化,不进行比较
*/
{
sum_high = sum_low = sum;
CopyRec(&stu_high, &rec);
CopyRec(&stu_low, &rec);
}
else
{
if (sum > sum_high)
{
sum_high = sum;/* 得到最高总分 */
CopyRec(&stu_high, &rec);/* 保存总分最高的学生的信息
*/
}
if (sum < sum_low)
{
sum_low = sum;/* 得到最低分 */
CopyRec(&stu_low, &rec);/* 保存总分最低的学生的信息
*/
}
}
/* subject highest and low */
if (count == 1)/* 同上面一样,执行初始化 */
{
CopyRec(&stu_math_high, &rec);
CopyRec(&stu_english_high, &rec);
CopyRec(&stu_compute_high, &rec);
CopyRec(&stu_philosophy_high, &rec);
CopyRec(&stu_PE_high, &rec);
CopyRec(&stu_math_low, &rec);
CopyRec(&stu_english_low, &rec);
CopyRec(&stu_compute_low, &rec);
CopyRec(&stu_philosophy_low, &rec);
CopyRec(&stu_PE_low, &rec);
}
else
{
/* High */
/* 保存各科的最高分的学生的信息 */
if (rec.Math > stu_math_high.Math)
CopyRec(&stu_math_high, &rec);
if (rec.English > stu_english_high.English)
CopyRec(&stu_english_high, &rec);
if (rec.Compute > stu_compute_high.Compute)
CopyRec(&stu_compute_high, &rec);
if (rec.Philosophy > stu_philosophy_high.Philosophy)
CopyRec(&stu_philosophy_high, &rec);
if (rec.PE > stu_PE_high.PE)
CopyRec(&stu_PE_high, &rec);
/* low */
/* 保存各科的最低分的学生的信息 */
if (rec.Math < stu_math_low.Math)
CopyRec(&stu_math_low, &rec);
if (rec.English < stu_english_low.English)
CopyRec(&stu_english_low, &rec);
if (rec.Compute < stu_compute_low.Compute)
CopyRec(&stu_compute_low, &rec);
if (rec.Philosophy < stu_philosophy_low.Philosophy)
CopyRec(&stu_philosophy_low, &rec);
if (rec.PE < stu_PE_low.PE)
CopyRec(&stu_PE_low, &rec);
}
}/* While End */
if (count < 1)
{
printf("
There is no record in the data file .
");
}
else
{
/* average */
/* 输出平均分的分段统计信息 */
printf("
The count in each segment :
");
printf(" < 60:%d
", i50);
printf("60 - 69:%d
", i60);
printf("70 - 79:%d
", i70);
printf("80 - 90:%d
", i80);
printf(" >= 90:%d
", i90);
printf(" ------------------------------------------");
getch();
/* highest and loeest */
/* 输出总分最高的学生的信息 */
printf("
The Highest Mark Student:
");
printf(" The Mark is : %d
", sum_high);
printf(" The student is :
");
Output_Rec(&stu_high);
/* 输出总分最高的学生的信息 */
printf("
The Lowest Mark Student:
");
printf(" The Mark is : %d
", sum_low);
printf(" The student is :
");
Output_Rec(&stu_low);
printf(" ------------------------------------------
");
getch();
/* subject highest and low */
/* 输出各科最高和最低分的统计信息 */
printf(" The HighestMath :
");
Output_Rec(&stu_math_high);
printf(" The Lowest Math :
");
Output_Rec(&stu_math_low);
printf(" ------------------------------------------
");
getch();/* 暂停 ,按任意键继续 */
printf(" The Highest English :
");
Output_Rec(&stu_english_high);
printf(" The Lowest English :
");
Output_Rec(&stu_english_low);
printf(" ------------------------------------------
");
getch();
printf(" The Highest Compute :
");
Output_Rec(&stu_compute_high);
printf(" The Lowest Compute :
");
Output_Rec(&stu_compute_low);
printf(" ------------------------------------------
");
getch();
printf(" The Highest Philosophy :
");
Output_Rec(&stu_philosophy_high);
printf(" The Lowest Philosophy :
");
Output_Rec(&stu_philosophy_low);
printf(" ------------------------------------------
");
getch();
printf(" The Highest PE :
");
Output_Rec(&stu_PE_high);
printf(" The Lowest PE :
");
Output_Rec(&stu_PE_low);
printf(" ------------------------------------------
");
}
fclose(fp);
}

void Find(int isFind_From_ID)/* 查找函数 */
{
char buf[30];/* 接受用户输入的条件的缓冲区 */
Student rec;
int find_count;/* 查找到的记录数目 */
FILE *fp;
find_count = 0;
fp = fopen(DATA_FILE, "rb");
if (fp == NULL)
{
printf("
Can not open the data file to search ...
");
return;
}
switch (isFind_From_ID)
{
case 5:/* ID,按 学号查找 */
printf("
Please Input the ID : ");
scanf("%s", buf);/* 提示用户输入 */
while (ReadData(fp, &rec))/* 读取数据 */
{
if (strcmp(rec.ID, buf) == 0)/* 比较 */
{
find_count ;
Output_Rec(&rec);/* 输出符合条件的记录 */
printf(" ------------------------------------------
");
}
}
break;
case 6:/* Name ,按 姓名 查找 */
printf("
Please Input the Name : ");
scanf("%s", buf);
while (ReadData(fp, &rec))
{
if (strcmp(rec.Name, buf) == 0)
{
find_count ;
Output_Rec(&rec);
printf(" ------------------------------------------
");
}
}
break;
default:
printf("
Please type right index ...
");/* 处理isFind_From_ID既不是5也不是6的情况
*/
}
if (find_count > 0)/* 输出找到的记录数目 */
{
printf("
Have find out%drecord
", find_count);
}
else
{
printf
("
I'm very sorry .
I failed to find out the one you want .
");
printf("
I suggest that you change some other key words .
");
}
fclose(fp);
}

int ReadData(FILE * fp, Student * Dest_Rec)/* 读取数据记录 */
{
int r;
if ((fp == NULL) || (Dest_Rec == NULL))
return 0;/* ERROR */
r = fread(Dest_Rec, sizeof(Student), 1, fp);
if (r != 1)
return 0;
return 1;
}

int WriteData(FILE * fp, Student * Src_Rec)/* 写入数据记录 */
{
int r;
if ((fp == NULL) || (Src_Rec == NULL))
return 0;/* ERROR */
r = fwrite(Src_Rec, sizeof(Student), 1, fp);
if (r != 1)
return 0;
return 1;
}

void Output_Rec(Student * stu)/* 在屏幕上输出 一个学生的信息 */
{
printf("
");
printf(" Name : %s", stu->Name);
printf("Sex : ");
if (stu->Sex == 'M' || stu->Sex == 'm')
printf("Male");
else
printf("Female");
printf("
ID : %sClass : %s
", stu->ID, stu->Class);
printf("Math = %dEnglish = %dCompute = %d
", stu->Math, stu->English,
stu->Compute);
printf("Philosophy = %dPE = %d
", stu->Philosophy, stu->PE);
printf("
");
}

void Input_Rec(Student * stu)/* 让用户输入 一个学生的各项信息
*/
{
if (stu == NULL)
return;
printf("
Name = ");
scanf("%s", stu->Name);
/* 下面这段代码实现只能输入 F ,f ,M ,m 的功能 */
printf("Sex = (F|M) ");
while (1)
{
stu->Sex = getch();/* 无回显输入 */
if (stu->Sex == 'F' || stu->Sex == 'f' || stu->Sex == 'M'
|| stu->Sex == 'm')
{
printf("%c", stu->Sex);/* 将用户输入的字符输出,模拟正常输入数据时的回显
*/
break;
}
}
/* 下面 给出提示,让用户输入结构体的各项内容 */
printf("
ID = ");
scanf("%s", stu->ID);
printf("
Class = ");
scanf("%s", stu->Class);
printf("
Math = ");
scanf("%d", &(stu->Math));
printf("
English = ");
scanf("%d", &(stu->English));
printf("
Compute = ");
scanf("%d", &(stu->Compute));
printf("
Philosophy = ");
scanf("%d", &(stu->Philosophy));
printf("
PE = ");
scanf("%d", &(stu->PE));
printf("
");
}

/* 因为结构体不能直接用 等号(=)赋值,写一个赋值函数 */
void CopyRec(Student * dest_stu, Student * src_stu)
{
/* 复制 源记录 的各项到 目标记录 */
strcpy(dest_stu->Name, src_stu->Name);
strcpy(dest_stu->ID, src_stu->ID);
strcpy(dest_stu->Class, src_stu->Class);
dest_stu->Sex = src_stu->Sex;
dest_stu->Math = src_stu->Math;
dest_stu->English = src_stu->English;
dest_stu->Compute = src_stu->Compute;
dest_stu->Philosophy = src_stu->Philosophy;
dest_stu->PE = src_stu->PE;
}

/*
题目分析 及 算法设计 :
题目中的各个功能都是相对独立的,所以我将各项功能以
带 编号 的菜单形式组织在屏幕上,用户通过 输入 编号
执行相应的功能。显示菜单的代码处于一个循环之中,当执行完一个子功能后,就又回到循环,显示主菜单,直到用户选择
退出 菜单。 这种操作方式比其它机制(如:主程序
程序参数)更简捷,不必每次用不同的参数重新运行程序,以实现相应的功能。
1. 查看文件记录内容的实现: 用循环读取文件内容,然后显示在屏幕上。
因为我们的数据是以结构体的形式存放在文件中的,所以
代码中用了块读取和块写入函数。 在循环中设置计数器来统计记录的个数。 2.
添加记录的实现:
让用户根据屏幕提示输入数据,完成对学生信息结构体各项的赋值,待取得足够数据后,将数据文件以“追加”方式打开,执行块写入,将整个结构体写入文件。
3. 删除记录的实现:
学号(ID)一般不会重复,所以我在程序中让用户输入想要删除的记录的学号(ID),然后在文件中查找,如果不是用户想要删除的记录(即ID不同),就保存在一个临时的文件中,这样,就将想要删除的记录与其它记录分离开了,最后,删除原来的数据文件,将临时文件的名字改为
原来数据文件的名字。 4. 统计功能的实现:
统计功能模块分为三个小模块:平均分的分数段统计,总分的最高和最低分统计,各科的最高和最低分统计。但我并不想分别来写,因为它们都要对所有记录进行扫描,而它们又互不干扰,所以我把它们组织在一个循环中,各自都有自己的计算代码和变量,所以这个
函数 中的局部变量 很多。 5. 查找功能的实现: 题目要求两种查找方式:按 学号(ID) , 按 姓名(Name)。 两者是独立的,所以我用了一个参数 isFind_From_ID
来表明是哪种查找方式,进而在在程序内部由一个 switch() 选择分支转向不同的代码段去执行。
具体的查找就是比较相应的项目是否与用户输入的一样,若一样就输出到屏幕。 */

学生信息与成绩管理系统的C语言课程设计。包含学生姓名、学号、性别...
答:void xiugai(); //修改信息 void shanchu(); //删除信息 void main() //main函数 { jiemian1();//函数点用 } void jiemian1() //主界面定义 { char a;printf("\n\n\n\n\t\t\t学 员 信 息 管 理 器\n\n\n\t\t\t C 语言课程设计练习一 \n\n\n\t...

跪求:用C语言编写学生信息管理系统
答:跪求:用C语言编写学生信息管理系统 学生信息放在students.dat文件中,文件由信息头和学生数据两部分组成:文件基本信息头结构定义(可自己扩展)typedefstruct{unsignedlongstuNum;//全体学生人数floatmax;//全体学生中的最... 学生信息放在students.dat文件中, 文件由信息头和学生数据两部分组成:文件基本信息头结构定义(可...

如何用C语言编写学生信息管理系统
答:参考如下学生信息管理系统的C源代码吧。include <stdio.h>#include <string.h>/*定义学生结构体*/struct Student{ char ID[20]; char Name[20]; float Mark1; float Mark2; float Mark3; float Average;};/*声明学生数组及学生数量*/struct Student students[1000];int...

C语言课程设计学籍信息管理
答:帮你完全按照这个写无偿的大家肯定都是没有时间的,我帮你找了一份基本满足你需求的源码你可以拿去改一改完成了你需求的百分之80如果你自己有哪些不懂再追问吧 include "stdio.h" #include "stdlib.h" #include "string.h" int shoudsave=0; /* */ struct student { char num[10];/* 学号...

c语言课程设计学籍管理系统
答:printf("请输入信息和成绩\n");printf("姓名,学号,英语,高数,C语言,体育:");printf("\n");stu p,q;p=q=(stu)malloc(sizeof(student));head=p;for(i=0;i<n;i++){ p->next=q;p=q;scanf("%s%d%d%d",q->name,&q->num,&q->grade.Escore,&q->grade.Mscore,&q->grade...

求用C语言编写一个简单的学生信息管理程序和课程设计报告
答:求用C语言编写一个简单的学生信息管理程序,能实现对学生信息的简单管理。要求:建立一个4个学生的信息登记表,每个学生的信息包括:学号,姓名,和3门课程的成绩(FOX,C,ENGLISH)。... 求用C语言编写一个简单的学生信息管理程序,能实现对学生信息的简单管理。要求:建立一个4个学生的信息登记表,每个学生的信息包括:...

用C语言编程学生信息管理系统!
答:具体要求如下:学生信息包括:学号,姓名,年龄,性别,出生年月,地址,电话,E-mail等。试设计一学生信息管理系统,使之能提供以下功能:系统以菜单方式工作(用键盘输入1~4之间的数来... 具体要求如下:学生信息包括:学号,姓名,年龄,性别,出生年月,地址,电话,E-mail等。试设计一学生信息管理系统,使之能提供以下功能:...

C语言程序设计 题目:学生信息管理系统
答:1题目:学生信息管理系统2程序要求:(1)学生信息录入功能1)用户从键盘输入每个学生的信息:学号、姓名、性别、数学、英语、政治、语文四门课成绩。2)可插入一个或多个学生信息到当... 1题目:学生信息管理系统 2 程序要求:(1)学生信息录入功能 1)用户从键盘输入每个学生的信息:学号、姓名、性别、数学、英语、政治...

用c语言编写学生信息管理系统
答:用c语言编写学生信息管理系统 1.定义结构体,应该至少包含如下属性:学号姓名性别年龄三门成绩2.要求所有功能均用函数来实现,要使main函数尽量的简洁3.录入学生信息(initStudentInfo())注意:学号的唯一性4.显示学... 1. 定义结构体,应该至少包含如下属性: 学号 姓名 性别 年龄 三门成绩 2. 要求所有功能均用函数...

求C语言高手编写学生信息管理系统
答:学生信息包括:学号,姓名,年龄,性别,出生年月,地址,电话,E-mail等。试设计一学生信息管理系统,使之能提供以下功能:(1)系统以菜单方式工作(2)学生信息录入功能(学生信息... 学生信息包括:学号,姓名,年龄,性别,出生年月,地址,电话,E-mail等。试设计一学生信息管理系统,使之能提供以下功能:(1) 系统以菜单方式...