C语言班级信息管理系统Word格式文档下载.docx
《C语言班级信息管理系统Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《C语言班级信息管理系统Word格式文档下载.docx(16页珍藏版)》请在冰豆网上搜索。
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;
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;
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();
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);
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"
请输入新姓名:
请输入新年龄:
请输入新性别:
请输入新出生年月:
请输入新地址:
case6:
请输入新电话:
case7:
请输入新E-mail:
}