- 系统开发背景
随着我国教育产业的飞速发展,社会对教育水平和教学管理软硬件的要求日益提高,尤其是对一个学校能够具有一套完善的教学管理软件提出了更多的要求。为了适应这种形式,教育系统尤其是大学不仅首先要有坚实的硬件基础,还要有一套完善的教学管理软件管理系统。而要实现这一功能,就要要求学校管理者配备一套高效的教育管理网络系统,以便在学校里实施良好的一套完善的管理且以最快的速度响应教师和学生的需求,及时为他们提供服务,为他们提供一个高效、便捷的环境。学生信息管理系统是校园网络中一个重要的应用系统,它大大改善了学校教学、科研与管理的基础环境,在一定程度上反映出学校管理现代化的水平。
- 系统需求
学生信息包括:学号,姓名,年龄,性别,出生年月,政治面貌,籍贯,家庭住址,
电话,E-mail等。试设计一学生信息管理系统,使之能提供以下功能:
(1)系统以菜单方式工作
(2)学生信息录入功能(学生信息用文件保存)
(3)学生信息浏览功能
(4)学生信息排序、查询功能
对信息进行排序,可以按学号,按姓名,按性别,按出生年月日,按籍贯进行查询
(5)信息统计
a)可以按性别,按出生年,按籍贯统计学生人数
b)可以按班级统计学生人数
c)可以按政治面貌统计学生人数
按班级统计学生党员人数,团员人数,以及所占比例,设计并输出统计报表。
(6)学生信息的删除与修改
设计要求:
*界面比较美观;
*有一定的容错能力,比如输入的成绩不在0~100之间,就提示不合法,要求重
新输入;
*最好用链表的方式实现。
- 系统总体设计
- 系统详细设计
系统中的每个功能模块流程图,伪代码
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct DATE {//学生生日年月日的结构体
int year;
int month;
int day;
}date;
typedef struct stu {//学生信息结构体
char num[20];
char name[20];
int old;
char sex[10];
date birthday;
char politic[20];
char native[20];
char address[200];
char phone[15];
char mail[50];
}STUDENT;
typedef struct stus {//存储学生信息的单链表
STUDENT students;
struct stus* next;
}stus;
int sum=0;//记录学生总数的全局变量
stus* enter(stus *head);//录入
int skim(stus* head);//浏览
int sort(stus* head);//学号排序
int query(stus* head);//查询
int statistics(stus* head);//统计
int delet(stus* head);//删除
int insert(stus* head);//插入
int input(stus *head) {//输入到文件的函数
FILE* fp;
int i;
if ((fp = fopen("text.xls", "a")) == NULL) {
printf("\t\033[5;31m 打开失败!!! \033[0m ");
return 0;
}//打开文件
stus* pu;
pu = head->next;
while (pu != NULL) {
fprintf(fp, "\n");
fprintf(fp, "%s\t", pu->students.num);
fprintf(fp, "%s\t", pu->students.name);
fprintf(fp, "%d\t", pu->students.old);
fprintf(fp, "%s\t", pu->students.sex);
fprintf(fp, "%d-%d-%d\t", pu->students.birthday.year, pu->students.birthday.month, pu->students.birthday.day);
fprintf(fp, "%s\t", pu->students.politic);
fprintf(fp, "%s\t", pu->students.native);
fprintf(fp, "%s\t", pu->students.address);
fprintf(fp, "%s\t", pu->students.phone);
fprintf(fp, "%s\t", pu->students.mail);
pu = pu->next;
}
}
void menu(stus *head)//菜单函数
{
stus* rear;
rear = head;
int key;
do
{
printf("\t\033[33;5m *************************** \033[0m \n");
printf("\t\033[40;33m _________________________ \033[0m \n");
printf("\t\033[40;33m |_____学生信息管理系统____| \033[0m \n");
printf("\t\033[40;33m |_________________________| \033[0m \n");
printf("\t\033[40;33m |_____1.录入学生信息______| \033[0m \n");
printf("\t\033[40;33m |_____2.学生信息浏览______| \033[0m \n");
printf("\t\033[40;33m |_____3.学生信息排序______| \033[0m \n");
printf("\t\033[40;33m |_____4.学生信息查询______| \033[0m \n");
printf("\t\033[40;33m |_____5.学生信息统计______| \033[0m \n");
printf("\t\033[40;33m |_____6.学生信息删除______| \033[0m \n");
printf("\t\033[40;33m |_____7.学生信息插入______| \033[0m \n");
printf("\t\033[40;33m |_____8.退出信息系统______| \033[0m \n");
printf("\t\033[40;33m |_________________________| \033[0m \n");
printf("\t\033[40;33m |_______选择你的操作______| \033[0m \n");
printf("\t\033[40;33m |_________________________| \033[0m \n");
printf("\t\033[33;5m *************************** \033[0m \n");
printf("\t\033[33;32m 你的选择是= \033[0m "); scanf("%d", &key);
switch (key)
{
case 1: {rear = enter(rear); }break;
case 2: {skim(head); }break;
case 3: {sort(head); }break;
case 4: {query(head); }break;
case 5: {statistics(head); }break;
case 6: {delet(head); }break;
case 7: {insert(head); }break;
}
} while (key!=8);
input(head);
}
stus* enter(stus *rear) {//输入信息单链表中的函数
int i, x;
int input(stus * head, int x);
printf("\t\033[33;32m 录入学生个数= \033[0m ");
scanf("%d", &x);
for (i = 0; i < x; i++) {
stus* student = (stus*)malloc(sizeof(stus));
student->next = NULL;
printf("\t\033[33;32m 学生学号: \033[0m ");
scanf("%s", student->students.num);
printf("\t\033[33;32m 学生姓名: \033[0m ");
scanf("%s", student->students.name);
printf("\t\033[33;32m 学生年龄(大于零): \033[0m ");
scanf("%d", &student->students.old);
if (student->students.old < 0)
{
printf("\t\033[5;31m 输入错误!!! \n\033[0m ");
break;
}
printf("\t\033[33;32m 学生性别(中文): \033[0m ");
scanf("%s", student->students.sex);
if (strcmp(student->students.sex, "男") != 0 && strcmp(student->students.sex, "女") != 0 && strcmp(student->students.sex, "f") != 0 && strcmp(student->students.sex,"F")!=0)
{
printf("\t\033[5;31m 输入错误!!! \n\033[0m ");
break;
};
printf("\t\033[33;32m 出生年月: \033[0m ");
scanf("%d %d %d", &student->students.birthday.year, &student->students.birthday.month, &student->students.birthday.day);
if (student->students.birthday.year < 1500|| student->students.birthday.year > 2021 ||student->students.birthday.month < 0|| student->students.birthday.month >12|| student->students.birthday.day< 0|| student->students.birthday.day>31)
{
printf("\t\033[5;31m 输入错误!!! \n\033[0m ");
break;
}
printf("\t\033[33;32m 政治面貌(党员或共青团员): \033[0m ");
scanf("%s", student->students.politic);
printf("\t\033[33;32m 学生籍贯: \033[0m ");
scanf("%s", student->students.native);
printf("\t\033[33;32m 家庭住址: \033[0m ");
scanf("%s", student->students.address);
printf("\t\033[33;32m 学生电话: \033[0m ");
scanf("%s", student->students.phone);
printf("\t\033[33;32m E-mail : \033[0m ");
scanf("%s", student->students.mail);
printf("\n");
rear->next = student;
rear = student;
sum++;
} return rear;
}
int skim(stus* head) {//输出函数
int i;
if (head->next == NULL)
{
printf("\t\033[5;31m 未输入信息!!! \n\033[0m ");
return(0);
}
stus* q;
char title[10][20] = { {"学号"},{"姓名"}, {"年龄"},{"性别"}, {"出生年月"}, {"政治面貌"}, {"籍贯"} ,{"家庭住址"}, {"电话"} ,{"E-mail"} };
for (i = 0; i < 10; i++)
{
printf("%s\t", title[i]);
}
printf("\n");
q = head->next;
while (q!= NULL){
printf( " %s\t", q->students.num);
printf( " %s\t", q->students.name);
printf( " %d\t", q->students.old);
printf( " %s\t", q->students.sex);
printf( " %d-%-d-%-d\t", q->students.birthday.year, q->students.birthday.month, q->students.birthday.day);
printf( " %s\t", q->students.politic);
printf( " %s\t", q->students.native);
printf( " %s\t", q->students.address);
printf( "%s\t", q->students.phone);
printf( " %s\t", q->students.mail);
printf("\n");
q = q->next;
}
}
int sort(stus* head) {//排序函数
if (head->next == NULL)
{
printf("\t\033[5;31m 未输入信息!!! \n\033[0m ");
return 0;
}
stus* temp = (stus*)malloc(sizeof(stus));
stus* p1 = head->next;
if (p1->next == NULL)
{
printf("\t\033[5;31m 只有一个人!!! \n\033[0m ");
return 0;
}
stus* p2 = p1->next;
p1 = head->next;
while (p1 != NULL)
{
p2 = p1->next;
while (p2 != NULL) {
if (strcmp(p1->students.num, p2->students.num) > 0)
{
temp->students = p2->students; p2->students = p1->students; p1->students = temp->students;
}
p2 = p2->next;
}
p1 = p1->next;
}
}
int query(stus* head) {//查询函数
int key;
do
{
printf("\t\033[33;5m *************************** \033[0m \n");
printf("\t\033[40;33m _________________________ \033[0m \n");
printf("\t\033[40;33m |_______学生信息查询______| \033[0m \n");
printf("\t\033[40;33m |________________________| \033[0m \n");
printf("\t\033[40;33m |_____1.学生学号查询______| \033[0m \n");
printf("\t\033[40;33m |_____2.学生姓名查询______| \033[0m \n");
printf("\t\033[40;33m |_____3.退出信息系统______| \033[0m \n");
printf("\t\033[40;33m |_________________________| \033[0m \n");
printf("\t\033[40;33m |_______选择你的操作______| \033[0m \n");
printf("\t\033[40;33m |_________________________| \033[0m \n");
printf("\t\033[33;5m *************************** \033[0m \n");
printf("\t\033[33;32m 你的选择是= \033[0m "); scanf("%d", &key);
switch (key)
{
case 1: {
char str[20];
int k = 0;
printf("\t\033[33;34m 学生学号= \033[0m ");
scanf("%s", str);
stus* n = (stus*)malloc(sizeof(stus));
n = head->next;
while (n != NULL && k!=1) {
if(strcmp(str,n->students.num)==0){
k = 1;
printf(" 学号:%-s\t", n->students.num);
printf(" 姓名:%s\t", n->students.name);
printf(" 年龄:%d\t", n->students.old);
printf(" 性别:%s\t", n->students.sex);
printf(" 出生年月:%d-%-d-%-d\t", n->students.birthday.year, n->students.birthday.month, n->students.birthday.day);
printf(" 政治面貌:%s\t", n->students.politic);
printf(" 籍贯:%s\t", n->students.native);
printf(" 家庭住址:%s\t", n->students.address);
printf(" 电话:%s\t", n->students.phone);
printf(" E-mail:%s\t", n->students.mail);
printf("\n");
}
n = n->next;
}if (k != 1)printf("\t\033[5;31m 未输入信息!!! \n\033[0m ");
}break;
case 2: {
int k = 0;
char str[20];
printf("\t\033[33;34m 学生姓名= \033[0m ");
scanf("%s", str);
stus* n = (stus*)malloc(sizeof(stus));
n = head->next;
while (n != NULL && k != 1) {
if (strcmp(str, n->students.name) == 0) {
k = 1;
printf("\t\033[33;34m 已找到!\n\033[0m ");
printf(" 学号:%s\t", n->students.num);
printf(" 姓名:%s\t", n->students.name);
printf(" 年龄:%d\t", n->students.old);
printf(" 性别:%s\t", n->students.sex);
printf(" 出生年月:%d-%-d-%-d\t", n->students.birthday.year, n->students.birthday.month, n->students.birthday.day);
printf(" 政治面貌:%s\t", n->students.politic);
printf(" 籍贯:%s\t", n->students.native);
printf(" 家庭住址:%s\t", n->students.address);
printf(" 电话:%s\t", n->students.phone);
printf(" E-mail:%s\t", n->students.mail);
printf("\n");
}
n = n->next;
}if (k != 1)printf("\t\033[5;31m 未输入信息!!! \n\033[0m ");
}break;
}
} while (key != 3); return 0;
}
int delet(stus* head) {//删除函数
int e;
if (sum==0)
{
printf("\t\033[5;31m 未输入内容!!! \n\033[0m ");
return 0;
}
printf("\t\033[33;32m 删除位置= \033[0m ");
scanf("%d", &e);
if (e > sum+1||e<1)
{
printf("\t\033[5;31m 位置错误!!! \n\033[0m ");
return 0;
}
stus* p; p = head;
stus* p2; p2 =p->next;
for (int i = 1; i < e; i++)
{
p = p->next;
p2 = p->next;
}
p->next = p2->next;
sum--;
}
int insert(stus* head) {//插入函数
int e;
stus* student = (stus*)malloc(sizeof(stus));
student->next = NULL;
printf("\t\033[33;32m 学生学号: \033[0m ");
scanf("%s", student->students.num);
printf("\t\033[33;32m 学生姓名: \033[0m ");
scanf("%s", student->students.name);
printf("\t\033[33;32m 学生年龄(大于零): \033[0m ");
scanf("%d", &student->students.old);
if (student->students.old < 0)
{
printf("\t\033[5;31m 输入错误!!! \n\033[0m ");
return 0;
}
printf("\t\033[33;32m 学生性别(中文): \033[0m ");
scanf("%s", student->students.sex);
if (strcmp(student->students.sex, "男") != 0 && strcmp(student->students.sex, "女") != 0 && strcmp(student->students.sex, "f") != 0 && strcmp(student->students.sex, "F") != 0)
{
printf("\t\033[5;31m 输入错误!!! \n\033[0m ");
return 0;
};
printf("\t\033[33;32m 出生年月: \033[0m ");
scanf("%d %d %d", &student->students.birthday.year, &student->students.birthday.month, &student->students.birthday.day);
if (student->students.birthday.year < 1500 || student->students.birthday.year > 2021 || student->students.birthday.month < 0 || student->students.birthday.month >12 || student->students.birthday.day < 0 || student->students.birthday.day>31)
{
printf("\t\033[5;31m 输入错误!!! \n\033[0m ");
return 0;
}
printf("\t\033[33;32m 政治面貌(党员或共青团员): \033[0m ");
scanf("%s", student->students.politic);
printf("\t\033[33;32m 学生籍贯: \033[0m ");
scanf("%s", student->students.native);
printf("\t\033[33;32m 家庭住址: \033[0m ");
scanf("%s", student->students.address);
printf("\t\033[33;32m 学生电话: \033[0m ");
scanf("%s", student->students.phone);
printf("\t\033[33;32m E-mail : \033[0m ");
scanf("%s", student->students.mail);
printf("\n");
printf("\t\033[33;32m 插入位置= \033[0m ");
scanf("%d", &e);
if (e > sum+1||e<0)
{
printf("\t\033[5;31m 位置错误!!! \n\033[0m ");
return 0;
}
stus* p;
p = head;
for (int i = 1; i < e; i++)
{
p = p->next;
}
student->next = p->next;
p->next = student;
sum++;
}
int statistics(stus* head) {//统计函数
int key;
do
{
printf("\t\033[33;5m *************************** \033[0m \n");
printf("\t\033[40;33m _________________________ \033[0m \n");
printf("\t\033[40;33m |_______学生信息统计______| \033[0m \n");
printf("\t\033[40;33m |________________________| \033[0m \n");
printf("\t\033[40;33m |_____1.学生性别统计______| \033[0m \n");
printf("\t\033[40;33m |_____2.党员人数统计______| \033[0m \n");
printf("\t\033[40;33m |_____3.退出信息系统______| \033[0m \n");
printf("\t\033[40;33m |_________________________| \033[0m \n");
printf("\t\033[40;33m |_______选择你的操作______| \033[0m \n");
printf("\t\033[40;33m |_________________________| \033[0m \n");
printf("\t\033[33;5m *************************** \033[0m \n");
printf("\t\033[33;32m 你的选择是= \033[0m "); scanf("%d", &key);
switch (key)
{
case 1: {
int M=0;
char str[20];
if (head->next == NULL)
{
printf("\t\033[5;31m 未输入信息!!! \n\033[0m ");
return 0;
}
stus* sex = (stus*)malloc(sizeof(stus));
sex = head->next;
while (sex != NULL) {
if (strcmp(sex->students.sex, "男") == 0 || strcmp(sex->students.sex, "m") == 0 || strcmp(sex->students.sex,"M")==0)
{
M++;
}sex = sex->next;
}printf("\n\t\033[33;34m 一共有%d名学生,女生%d名,男生%d名 \n\033[0m ", sum, sum - M, M);
}break;
case 2: {
int D=0;
if (head->next == NULL)
{
printf("\t\033[5;31m 未输入信息!!! \n\033[0m ");
return 0;
}
stus* d = (stus*)malloc(sizeof(stus));
d = head->next;
while (d != NULL) {
if (strcmp(d->students.politic, "党员") == 0)
{
D++;
} d = d->next;
}printf("\n\t\033[33;34m 一共有%d名学生,团员%d名,党员%d名\n\033[0m ", sum, sum - D,D);
}break;
}
} while (key != 3); return 0;
}
int main() {//主函数
stus* head = (stus*)malloc(sizeof(stus));
head->next = NULL;
FILE* fp;
int i=0;
if ((fp = fopen("text.xls", "w")) == NULL) {
printf("\t\033[5;31m 打开失败!!! \033[0m ");
return 0;
}
char title[10][20] = { {"学号"},{"姓名"}, {"年龄"},{"性别"}, {"出生年月"}, {"政治面貌"}, {"籍贯"} ,{"家庭住址"}, {"电话"} ,{"E-mail"} };//xls表头数组
for (i = 0; i < 10; i++) {
fprintf(fp, "%s\t", title[i]);
}建立数组
menu(head);
return 0;
}