当前位置:文档之家› 学生证信息管理系统

学生证信息管理系统

1系统的意义及其功能本系统为《学生证管理程序》。

系统任务描述:假设某校学生学生证基本信息主要包括:学号、姓名、所在系、班级等,本系统应能对这些基本信息进行管理,并要求具有以下功能:(1)通过键盘输入某位学生的学生证信息。

学生证包含的信息请参看自己的学生证;(2)给定学号,显示某位学生的学生证信息;(3)给定某个班级的班号,显示该班所有学生的学生证信息;(4)给定某位学生的学号,修改该学生的学生证信息;2系统的功能结构图以及调用关系3系统功能详细分析学生证管理系统需要完成的功能主要有:从主函数进入各个子函数:子函数包括学生证信息的键入、查询信息的功能、修改学生证信息的功能、退出系统。

具体功能如下:3.1学生证信息的键入学生证管理系统3.2 查询信息的功能查询记录的主要功能是通过不同的查询式查询学生的信息。

先是进入查询界面,再选择查询的式,选择后将输出该学生的信息。

共分为两种:○1 给定某个学生的学号,显示该学生的学生证信息; ○2 给定某个班级的班号,按学号排序来显示该班所有学生的学生证信息; 按班级排序来显示该班所有学生的学生证信息;3.2.1 输入学号,显示该生的学生证信息3.2.2 输入班号,显示该班所有学生的学生证信息学生证管理系统3.3 修改学生证信息的功能4 运行界面主菜单界面修改信息功能修改信息的主要功能是通过输入某位学生的学号来修改该生的学生证信息。

先是进入修改界面,再输入学号,输入后,将输出该生的学生证信息,再选择是否修改此记录,选择是,则输入修改的信息,并保存修改。

开始主菜单修改学生证信息功能输入学号显示该生学生证信息是否修改写入并保存文件YN学生证管理系统学生证键入的界面个人学生证信息显示界面显示班级信息的选择输出式的界面学生证管理系统按学号排序显示该班所有学生的学生证信息界面按姓名排序显示该班所有学生的学生证信息界面显示班级信息的退出界面修改学生证信息的界面学生证管理系统5系统使用说明1、进入程序时,先以菜单形式显示所有命令,然后用户通过菜单项选择操作;例如:1 学生证信息的键入2 输入学号,显示该生学生证信息3 输入班号,显示该班所有学生的学生证信息4 给定学号,修改该生学生证信息5 退出系统请选择[1/2/3/4/5]:2、键入学生证信息时,按照所给定的格式输入。

3、查询信息是按学生学号和班号的形式进行查询,填入学号后,则显示出该生所有信息;选择按班号查询功能后,在选择显示输出式,分两种:一种按学号排序;另一种是按姓名排序。

选定后,再填入班号,则显示出该班所有学生的学生证信息(按已选定的排序式显示)。

4、修改信息是按输入学号的形式进行修改,填入后,则显示出该生所有信息,然后询问是否修改,若回答“y”(大小写通用),则输入新值,否则不作修改。

6 C语言源程序代码#include <stdio.h>#include <windows.h> //用来使用清屏函数#include <malloc.h>#include <string.h>#include <stdlib.h>#define LEN sizeof(struct STUcard)struct STUcard *creat();void viewperson();void viewclass();void number();void name();void change();struct STUcard *save();struct date{int year;int month;int day;}; //定义用来嵌套的结构体struct STUcard{int number;char name[20];char sex[10];char department[20];char classnumber[10];struct date timeofenter; //嵌套结构体char IDnumber[30];struct date birthday;struct STUcard *next;}; //定义结构体void main(){char c;int n=0;struct STUcard *head;char build; //创建文件FILE *fp;fp=fopen("XX.out","rb");if(fp==NULL){printf("文件不存在,请创建(Y or N)");scanf("%c",&build);if(build=='Y')fp=fopen("XX.out","wb");elseexit(0);}do{system("cls"); //清屏printf("*****************************************\n");printf(" 1: 输入学生证信息\n");printf(" 2: 查找个人信息\n");printf(" 3: 查找班级里所有学生的学生证信息\n");printf(" 4: 修改学生证信息\n");printf(" 5: 退出\n");printf("*****************************************\n");printf(" \n");printf("请选择输入选项[1\\2\\3\\4\\5]:>");do{c=getchar();}while(c!='1'&&c!='2'&&c!='3'&&c!='4'&&c!='5');学生证管理系统getchar();switch(c){case '1': head=creat(); break;case '2': viewperson(head); break;case '3': viewclass(head); break;case '4': change(head); break;case '5': exit(0); break;}printf(" 按任意键返回主菜单:\n");flushall();getchar();printf("%d",n);system("cls");}while(1);}int n;struct STUcard *creat() //录入学生证信息函数{struct STUcard *head,*p1,*p2;n=0;head=NULL;p1=p2=(struct STUcard *)malloc(LEN);printf("请按以下格式输入学生证信息,注意每个数据之间间隔一个空格!\n以学号为00000000结束录入,并且剩下的信息字符用“0”代替输入注意:输入格式不变!:\n");printf("学号姓名性别院系班级入学时间(年月日)身份证号出生日期(年月日)\n");scanf("%d %s %s %s %s %d %d %d %s %d %d %d",&p1->number,p1->name,p1->sex,p1->department,p1->classnumber,&p1->timeofenter.year,&p1->timeofenter.month,&p1->timeofenter.day,p1->IDnumber,&p1->birthday.year,&p1->birthday.month,&p1->birthday.day);while(p1->number!=00000000){n=n+1;if(n==1) head=p1;else p2->next=p1;p2=p1;p1=(struct STUcard *)malloc(LEN);scanf("%d %s %s %s %s %d %d %d %s %d %d %d",&p1->number,p1->name,p1->sex,p1->department,p1->classnumber,&p1->timeofenter.year,&p1->timeofenter.month,&p1->timeofenter.day,p1->IDnumber, &p1->birthday.year,&p1->birthday.month,&p1->birthday.day);}p2->next=NULL;free(p1);save(head); //保存文件return(head); //把已录入信息的链表头指针返回给住函数}void viewperson(struct STUcard * head) //查找个人信息函数{int m,a=0;struct STUcard *p;printf("请输入学号:");printf(" \n ");scanf("%d",&m);p=head; //获取头指针,以使用链表while(p->next!=NULL) //判断是否为空指针{if(p->number==m){printf("学号:%d\n姓名:%s\n性别:%s\n院系:%s\n班级:%s\n入学时间:%d年%d月%d日\n身份证号:%s\n出生日期:%d年%d月%d日\n",p->number,p->name,p->sex,p->department,p->classnumber,p->timeofenter.year,p->timeofenter.month,p->timeofenter.day,p->IDnumber,p->birthday.year,p->birthday.month,p->birthday.day);printf("\n");a=a+1;}p=p->next; //结点后移}if(p->number==m){printf("学号:%d\n姓名:%s\n性别:%s\n院系:%s\n班级:%s\n入学时间:%d年%d月%d日\n身份证号:%s\n出生日期:%d年%d月%d日\n",p->number,p->name,p->sex,p->department,p->classnumber,p->timeofenter.year,p->timeofenter.month,p->timeofenter.day,p->IDnumber,p->birthday.year,p->birthday.month,p->birthday.day);printf("\n");a=a+1;}学生证管理系统printf("\n");printf("共%d人\n",a);if(a==0) printf(" 对不起,查无此人!\n");}void viewclass(struct STUcard * head) //查找班级信息函数{char c;void number();void name();do{system("cls"); //清屏printf("****************************************\n");printf(" 1: 按学号排序输出\n");printf(" 2: 按姓名排序输出\n");printf(" 3: 退出\n");printf("****************************************\n");printf(" \n");printf("请选择输入选项[1\\2\\3]:>");do{c=getchar();}while(c!='1'&&c!='2'&&c!='3');getchar();switch(c){case '1': number(head); break;case '2': name(head); break;case '3': exit(0); continue;}printf(" 按任意键返回上层菜单:\n");flushall();getchar();system("cls");}while(1);}void number(struct STUcard *head) //按学号排序{char c[10];int h1,a=0,i,j,k,w;char hname[20];char hsex[20];char hdepartment[20];char hclassnumber[10];char hIDnumber[30];struct date htimeofenter;struct date hbirthday;struct STUcard *p,*p2,*p3;p=head;p2=head;p3=p2->next;for(k=1;;k++) //用来确定链表中共多少个结点{if(p->next!=NULL) p=p->next;else break;}for(i=0;i<k-1;i++){p2=head;p3=p2->next;for(j=0;j<k-1-i;j++){if(p2->number>p3->number){h1=p2->number;strcpy(hname,p2->name);strcpy(hsex,p2->sex);strcpy(hdepartment,p2->department);strcpy(hclassnumber,p2->classnumber);strcpy(hIDnumber,p2->IDnumber);htimeofenter=p2->timeofenter;hbirthday=p2->birthday;p2->number=p3->number;strcpy(p2->name,p3->name);strcpy(p2->sex,p3->sex);strcpy(p2->department,p3->department);strcpy(p2->classnumber,p3->classnumber);strcpy(p2->IDnumber,p3->IDnumber);p2->timeofenter=p3->timeofenter;p2->birthday=p3->birthday;p3->number=h1;strcpy(p3->name,hname);strcpy(p3->sex,hsex);学生证管理系统strcpy(p3->department,hdepartment);strcpy(p3->classnumber,hclassnumber);strcpy(p3->IDnumber,hIDnumber);p3->timeofenter=htimeofenter;p3->birthday=hbirthday;}p2=p3;p3=p3->next;}}printf("请输入班级:\n");scanf("%s",&c);p=head;for(w=1;w<=k;w++){printf("\n");if(strcmp(p->classnumber,c)==0){printf("学号:%d\n姓名:%s\n性别:%s\n院系:%s\n班级:%s\n入学时间:%d年%d月%d日\n身份证号:%s\n出生日期:%d年%d月%d日\n",p->number,p->name,p->sex,p->department,p->classnumber,p->timeofenter.year,p->timeofenter.month,p->timeofenter.day,p->IDnumber,p->birthday.year,p->birthday.month,p->birthday.day);a=a+1;}p=p->next;}printf("\n");printf("共%d人\n",a);if(a==0) printf("对不起无此班级");}void name(struct STUcard *head) //按姓名排序{char c[10];int h1,a=0,i,j,k,w;char hname[20];char hsex[20];char hdepartment[20];char hclassnumber[10];char hIDnumber[30];struct date htimeofenter;struct date hbirthday;struct STUcard *p,*p2,*p3;p=head;p2=head;p3=p2->next;for(k=1;;k++){if(p->next!=NULL) p=p->next;else break;}for(i=0;i<k-1;i++){p2=head;p3=p2->next;for(j=0;j<k-1-i;j++){if(strcmp(p2->name,p3->name)>0){h1=p2->number;strcpy(hname,p2->name);strcpy(hsex,p2->sex);strcpy(hdepartment,p2->department);strcpy(hclassnumber,p2->classnumber);strcpy(hIDnumber,p2->IDnumber);htimeofenter=p2->timeofenter;hbirthday=p2->birthday;p2->number=p3->number;strcpy(p2->name,p3->name);strcpy(p2->sex,p3->sex);strcpy(p2->department,p3->department);strcpy(p2->classnumber,p3->classnumber);strcpy(p2->IDnumber,p3->IDnumber);p2->timeofenter=p3->timeofenter;p2->birthday=p3->birthday;p3->number=h1;strcpy(p3->name,hname);strcpy(p3->sex,hsex);strcpy(p3->department,hdepartment);strcpy(p3->classnumber,hclassnumber);strcpy(p3->IDnumber,hIDnumber);p3->timeofenter=htimeofenter;p3->birthday=hbirthday;}p2=p3;p3=p3->next;学生证管理系统}}printf("请输入班级:\n");scanf("%s",&c);p=head;for(w=1;w<=k;w++){printf("\n");if(strcmp(p->classnumber,c)==0){printf("学号:%d\n姓名:%s\n性别:%s\n院系:%s\n班级:%s\n入学时间:%d年%d月%d日\n身份证号:%s\n出生日期:%d年%d月%d日\n",p->number,p->name,p->sex,p->department,p->classnumber,p->timeofenter.year,p->timeofenter.month,p->timeofenter.day,p->IDnumber,p->birthday.year,p->birthday.month,p->birthday.day);a=a+1;}p=p->next;}printf("\n");printf("共%d人\n",a);if(a==0) printf("对不起无此班级");}void change(struct STUcard * head) //修改信息{ int x;struct STUcard *p1,*p2;printf("输入要修改学生的学号\n");scanf("%d",&x);p1=head;while((p1->number!=x)&&(p1->next!=NULL)){p2=p1;p1=p1->next;}if(p1->number==x){printf("请输入需要修改的信息:\n");printf("输入学号:");scanf("%d",&p1->number);printf("输入姓名:");scanf("%s",p1->name);printf("输入性别:");scanf("%s",p1->sex);printf("输入院系:");scanf("%s",p1->department);printf("输入班级:");scanf("%s",p1->classnumber);printf("输入入学时间(年月日):");scanf("%d %d %d",&p1->timeofenter.year,&p1->timeofenter.month,&p1->timeofenter.day);printf("输入身份证号:");scanf("%s",p1->IDnumber);printf("输入出生日期(年月日):");scanf("%d %d %d",&p1->birthday.year,&p1->birthday.month,&p1->birthday.day);printf("信息已修改");save(head);}else printf("%d 找不到该学号!\n",x);}struct STUcard *save(struct STUcard *head) //________保存函数{ FILE *fp;struct STUcard *p;p=head;fp=fopen("XX.out","w+");if(fp==0){printf("不能打开文件");exit(0);}while (p){fprintf(fp,"学号:%d\n姓名:%s\n性别:%s\n院系:%s\n班级:%s\n入学时间:%d年%d 月%d日\n身份证号:%s\n出生日期:%d年%d月%d日\n",p->number,p->name,p->sex,p->department,p->classnumber,p->timeofenter.year,p->timeofenter.month,p->timeofenter.day,p->IDnumber,p->birthday.year,p->birthday.month,p->birthday.day);printf("\n");p=p->next;}printf("\n文件保存成功!\n",n);fclose(fp);return head; //返回后结点}7心得体会通过这次的C语言程序设计,让我意识到自己的基础还不是太扎实,发现自己在编程面还有些不足,学生证管理系统有一些小小的错误不能避免。

相关主题