学生信息管理系统程序设计Word格式.docx

上传人:b****6 文档编号:18233273 上传时间:2022-12-14 格式:DOCX 页数:18 大小:27.78KB
下载 相关 举报
学生信息管理系统程序设计Word格式.docx_第1页
第1页 / 共18页
学生信息管理系统程序设计Word格式.docx_第2页
第2页 / 共18页
学生信息管理系统程序设计Word格式.docx_第3页
第3页 / 共18页
学生信息管理系统程序设计Word格式.docx_第4页
第4页 / 共18页
学生信息管理系统程序设计Word格式.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

学生信息管理系统程序设计Word格式.docx

《学生信息管理系统程序设计Word格式.docx》由会员分享,可在线阅读,更多相关《学生信息管理系统程序设计Word格式.docx(18页珍藏版)》请在冰豆网上搜索。

学生信息管理系统程序设计Word格式.docx

#include<

stdio、h>

malloc、h>

string、h>

io、h>

#defineNULL0

#defineLENsizeof(structstudent)

#define"

c:

\student、txt"

structstudent

{

longintnum;

charname[20];

intage;

charsex[4];

charbirthday[10];

charaddress[30];

longinttele_num;

charE_mail[20];

structstudent*next;

};

intTOTAL_NUM=0;

structstudent*head=NULL;

voidwelcome();

voidmainmenu();

voidrecord();

voidinsert(structstudent*stu);

voiddisplay(structstudent*stu);

voiddisplayAll();

voidquery();

voidquery_by_num();

voidquery_by_name();

voidreadData();

voidwriteData();

voidfreeAll();

voiddel();

voidchange();

voiddevise(structstudent*p);

intmain()

charuserName[9];

charuserPWD[7];

inti;

welcome();

for(i=0;

i<

3;

i++)

{

printf("

\n管理员初始用户名与密码均为admin\n"

);

请输入您的用户名:

"

scanf("

%s"

userName);

\n请输入您的密码:

userPWD);

if((strcmp(userName,"

admin"

)==0)&

&

(strcmp(userPWD,"

)==0))

//用户名与密码正确,显示主菜单

mainmenu();

break;

}

else

if(i<

2)

//用户名或密码错误,提示用户重新输入

用户名或密码错误,请重新输入!

//连续3次输错用户名或密码,退出系统。

您已连续3次将用户名或密码输错,系统将退出!

return0;

}

//显示欢迎信息

voidwelcome()

+---------------------------+\n"

||\n"

|欢迎使用学生信息管理系统|\n"

//系统主菜单

voidmainmenu()

intchoice;

choice=-1;

readData();

\n温馨提示:

为保证您的操作得到保存,请按正常顺序退出系统^_^\n"

do

\n\n\n"

\t\t\t--------------------------------\n"

\t\t\t+学生信息管理系统|\n"

\t\t\t+[1]----录入学生信息|\n"

\t\t\t+[2]----浏览学生信息|\n"

\t\t\t+[3]----查询学生信息|\n"

\t\t\t+[4]----删除学生信息|\n"

\t\t\t+[5]----修改学生信息|\n"

\t\t\t+[0]----退出系统|\n"

\t\t\t+*·

|\n"

请输入您的选择:

%d"

&

choice);

switch(choice)

case0:

writeData();

freeAll();

exit(0);

case1:

record();

case2:

displayAll();

case3:

query();

case4:

del();

case5:

change();

default:

\n无效选项!

while(choice!

=0);

//录入学生信息

voidrecord()

{

structstudent*p0;

p0=(structstudent*)malloc(LEN);

请输入学生的学号:

%ld"

&

p0->

num);

请输入学生的姓名:

p0->

name);

请输入学生的年龄:

age);

请输入学生的性别:

sex);

请输入学生的出生年月:

birthday);

请输入学生的地址:

address);

请输入学生的电话:

tele_num);

请输入学生的E-mail:

E_mail);

insert(p0);

该学生的信息为:

\n"

-------------------------------------------------------------------------------"

学号\t姓名\t年龄\t性别\t出生年月\t\t地址\t电话\tE-mail\n"

display(p0);

voidinsert(structstudent*stu)

structstudent*p0,*p1,*p2;

p1=head;

p0=stu;

if(head==NULL)

head=p0;

p0->

next=NULL;

while((p0->

num>

p1->

num)&

(p1->

next!

=NULL))

p2=p1;

p1=p1->

next;

if(p0->

num<

=p1->

num)

if(head==p1)

p2->

next=p0;

next=p1;

}

TOTAL_NUM++;

voiddisplay(structstudent*p)

%ld\t%s\t%d\t%s\t%s\t%s\t%ld\t%s\n"

p->

num,p->

name,p->

age,p->

sex,p->

birthday,p->

address,p->

tele_num,p->

//浏览学生信息

voiddisplayAll()

structstudent*p;

学生总数:

%d\n"

TOTAL_NUM);

p=head;

if(head!

=NULL)

{

\n学号\t姓名\t年龄\t性别\t出生年月\t地址\t电话\tE-mail\n"

display(p);

p=p->

while(p!

=NULL);

//查询学生信息

voidquery()

+--------------------+\n"

|按学号查询请按1|\n"

|按姓名查询请按2|\n"

|取消请按0|\n"

return;

query_by_num();

case2:

query_by_name();

//按学号查询学生信息

voidquery_by_num()

intnum;

structstudent*p1;

if(head==NULL)

无学生记录!

p1=head;

while(num!

=p1->

num&

next!

=NULL)

p1=p1->

if(num==p1->

display(p1);

没有该学生记录,请核对!

//按姓名查询学生信息

voidquery_by_name()

name);

while(strcmp(name,p1->

name)&

if(!

strcmp(name,p1->

name))

//写入文件

voidwriteData()

FILE*fp;

//文件指针

fp=fopen(,"

w"

if(!

fp)

文件打开错误!

fprintf(fp,"

for(p=head;

p!

=NULL;

p=p->

next)

p->

fclose(fp);

voidfreeAll()

structstudent*p1,*p2;

p1=p2=head;

while(p1)

p2=p1->

free(p1);

p1=p2;

//读取文件

voidreadData()

r"

fscanf(fp,"

TOTAL_NUM);

head=p1=p2=(structstudent*)malloc(LEN);

&

p1->

num,p1->

name,&

age,p1->

sex,p1->

birthday,p1->

address,&

tele_num,p1->

while(!

feof(fp))

p1=(structstudent*)malloc(LEN);

//删除学生信息

voiddel()

请输入您要删除的学生的学号:

while(num!

if(p1==head)

head=p1->

elsep2->

next=p1->

TOTAL_NUM--;

//修改学生信息

voidchange()

请输入您要修改的学生的学号:

devise(p1);

voiddevise(structstudent*p)

请选择您要修改的学生的信息内容:

+----------------------+\n"

|姓名请按1|\n"

|年龄请按2|\n"

|性别请按3|\n"

|出生年月请按4|\n"

|地址请按5|\n"

|电话请按6|\n"

|E-mail请按7|\n"

请输入新姓名:

请输入新年龄:

p->

请输入新性别:

请输入新出生年月:

请输入新地址:

case6:

请输入新电话:

case7:

printf("

请输入新E-mail:

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 艺术

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1