资源简介
程序功能
(1)存取功能,能够从磁盘上的文本文件读取学生信息,并将内存中的学生信息保存到磁盘上的文件中。学生信息包括学号、姓名、数学成绩、英语成绩、政治成绩。
(2)查询功能,分别能按学生学号和学生姓名进行查找学生信息,根据提示输入不同的数字,进行不同的查找方式。
(3)学生成绩统计功能,能够统计学生的平均成绩和总成绩。
(4)插入功能,能够插入学生信息,若新插入的学号应经存在系统中,会进行提示,此时不允许在插入具有相同学号的学生信息。
(5)修改功能,先用学号或姓名关键字查找要修改的学生的信息,若找到,则可进行修改。
(6)删除功能,能够删除指定的学生信息。

代码片段和文件信息
/* File:StuManage.c
*
* 学生成绩管理信息系统
* 作者:阿龙
* 使用时自己先建一个名为stumanage.txt的文件
* 不然学生信息不能保存到磁盘上去的啊
*/
#include
#include
#include
#include
#define LEN sizeof(struct students)
/*定义结构体,用来存放学生信息*/
struct score
{
double math;
double english;
double politics;
};
struct students
{
char num[12];
char name[15];
struct score sco;
struct students *next;
};
/*开始运行程序时,从stumanage.txt文件读取学生信息到内存中,并返回头指针*/
struct students *InputMem(struct students *head)
{
FILE *fp;
struct students *temp = NULL *tail = NULL;
fp = fopen(“stumanage.txt“ “r+“);
if (NULL == fp)
{
printf(“不能打开文件\n“);
return head;
}
while (!feof(fp))
{
temp = (struct students *)malloc(LEN);
/*判断是否申请到内存空间,若没有返回头指针,否则跳过if继续执行*/
if (NULL == temp)
{
printf(“没有申请到足够的内存空间\n“);
return head;
}
fread(temp LEN 1 fp);
if (head == NULL)
{
head = temp;
tail = temp;
}
else
{
tail->next = temp;
tail = temp;
}
}
temp->next = NULL; /*将动态链表最后节点的尾指针设为NULL*/
fclose(fp);
return head;
}
/*退出时将内存中的学生信息写入到stumanage.txt文件中去*/
void OutputMem(struct students *head)
{
FILE *fp;
struct students *temp = NULL;
fp = fopen(“stumanage.txt“ “r+“);
if (head != NULL)
{
temp = head;
while (temp->next != NULL)
{
fwrite(temp LEN 1 fp);
temp = temp->next;
}
}
fclose(fp);
}
/*程序运行结束时释放申请的内存空间*/
void DelMem(struct students *head)
{
struct students *temp = head;
if (temp !=NULL)
{
while (temp->next !=NULL)
{
head = temp->next;
free(temp);
temp = head;
}
free(head);
}
}
/*打印信息管理系统功能使用说明*/
void Instruction(void)
{
printf(“********************************************\n“);
printf(“ 学生成绩管理信息系统 \n\n“);
printf(“ 使用说明\n“);
printf(“ 查看所有信息请按 1 学生信息查询请按 2\n“);
printf(“ 学生信息插入请按 3 学生信息修改请按 4\n“);
printf(“ 学生信息删除请按 5 学生成绩统计请按 6\n“);
printf(“ 退出请按 0\n\n“);
printf(“********************************************\n“);
}
/*打印学生信息的表头*/
void Printtitle()
{
printf(“ 学号 姓名 数学 英语 政治“);
}
/*输出temp指针指向的单个学生的信息*/
void PrintStuInfo(struct students *temp)
{
printf(“%6s%6s%6.1lf%6.1lf%6.1lf“ temp->num temp->name
temp->sco.mathtemp->sco.english temp->sco.politics);
}
/*查看所有学生信息*/
void Chakan(struct students *head)
{
struct students *temp = head;
if (NULL == head)
{
printf(“没有学生信息,请先输入后再查看学生信息\n\n“);
}
else
{
printf(“ 学生的所有信息如下:\n\n“);
Printtitle();
printf(“\n“);;
while (temp->next!=NULL)
{
PrintStuInfo(temp);
printf(“\n“);
temp = temp->next;
}
printf(“\n\n“);
}
}
/*按学生学号进行查询*/
struct students *NumQuery(struct students *head char number[])
{
struct students *temp = head;
while (temp->next != NULL)
{
if (!strcmp(temp->num number))
{
return temp;
}
temp = temp->next;
}
return NULL;
}
/*按学生姓名进行查询*/
struct students *NameQuery(stru
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9573 2008-09-21 20:15 学生成绩管理信息系统\stumanage.c
文件 134656 2008-09-21 20:27 学生成绩管理信息系统\课程设计.doc
目录 0 2008-09-21 20:25 学生成绩管理信息系统
----------- --------- ---------- ----- ----
144229 3
相关资源
- 操作系统c语言模拟文件管理系统844
- C语言开发实战宝典
- C++中头文件与源文件的作用详解
- C语言代码高亮html输出工具
- 猜数字游戏 c语言代码
- C语言课程设计
- 数字电位器C语言程序
- CCS FFT c语言算法
- 使用C语言编写的病房管理系统
- 通信过程中的RS编译码程序(c语言)
- 计算机二级C语言上机填空,改错,编
- 用回溯法解决八皇后问题C语言实现
- 简易教务管理系统c语言开发文档
- 操作系统课设 读写者问题 c语言实现
- 小波变换算法 c语言版
- C流程图生成器,用C语言代码 生成C语
- 3des加密算法C语言实现
- 简单的C语言点对点聊天程序
- 单片机c语言源程序(51定时器 八个按
- 个人日常财务管理系统(C语言)
- c语言电子商务系统
- 小甲鱼C语言课件 源代码
- 将图片转换为C语言数组的程序
- C语言实现的一个内存泄漏检测程序
- DES加密算法C语言实现
- LINUX下命令行界面的C语言细胞游戏
- 用单片机控制蜂鸣器播放旋律程序(
- 学校超市选址问题(数据结构C语言版
- 电子时钟 有C语言程序,PROTEUS仿真图
- 尚观培训linux许巍老师关于c语言的课
评论
共有 条评论