C语言之学生管理系统Word文档下载推荐.docx

上传人:wj 文档编号:1457771 上传时间:2023-04-30 格式:DOCX 页数:14 大小:143.27KB
下载 相关 举报
C语言之学生管理系统Word文档下载推荐.docx_第1页
第1页 / 共14页
C语言之学生管理系统Word文档下载推荐.docx_第2页
第2页 / 共14页
C语言之学生管理系统Word文档下载推荐.docx_第3页
第3页 / 共14页
C语言之学生管理系统Word文档下载推荐.docx_第4页
第4页 / 共14页
C语言之学生管理系统Word文档下载推荐.docx_第5页
第5页 / 共14页
C语言之学生管理系统Word文档下载推荐.docx_第6页
第6页 / 共14页
C语言之学生管理系统Word文档下载推荐.docx_第7页
第7页 / 共14页
C语言之学生管理系统Word文档下载推荐.docx_第8页
第8页 / 共14页
C语言之学生管理系统Word文档下载推荐.docx_第9页
第9页 / 共14页
C语言之学生管理系统Word文档下载推荐.docx_第10页
第10页 / 共14页
C语言之学生管理系统Word文档下载推荐.docx_第11页
第11页 / 共14页
C语言之学生管理系统Word文档下载推荐.docx_第12页
第12页 / 共14页
C语言之学生管理系统Word文档下载推荐.docx_第13页
第13页 / 共14页
C语言之学生管理系统Word文档下载推荐.docx_第14页
第14页 / 共14页
亲,该文档总共14页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

C语言之学生管理系统Word文档下载推荐.docx

《C语言之学生管理系统Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《C语言之学生管理系统Word文档下载推荐.docx(14页珍藏版)》请在冰点文库上搜索。

C语言之学生管理系统Word文档下载推荐.docx

//查询学生信息

voidquery_by_num();

//按学号查询学生信息

voidquery_by_name();

voidreadData();

//读取文件里学生的信息

voidwriteData();

//向文件写入学生信息

voidfreeAll();

//清空链表内容

voiddel();

//删除学生信息

voidchange();

//更改学生信息

voidsort();

//排序

voiddevise(structstudent*p);

//选择更改内容

intmain(void)

mainmenu();

return0;

}

//系统主菜单

voidmainmenu()

intchoice;

choice=-1;

readData();

printf("

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

);

\t\t\t|欢迎使用通信工程专业学生信息管理系统|\n"

\t\t\t本程序需要在当前目录下建立student.txt才可正常运行\n"

do

{

printf("

\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[6]----排序|\n"

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

请输入您的选择"

scanf("

%d"

&

choice);

switch(choice)

{

case0:

writeData();

freeAll();

exit(0);

case1:

record();

break;

case2:

displayAll();

case3:

query();

case4:

del();

case5:

change();

case6:

sort();

default:

printf("

\n无效选项!

"

}

}while(choice!

=0);

}

//录入学生信息

voidrecord()

structstudent*p0;

p0=(structstudent*)malloc(LEN);

\t\t\t请输入学生的姓名:

scanf("

%s"

p0->

name);

\t\t\t请输入学生的学号:

%ld"

&

p0->

num);

\t\t\t请输入学生的性别:

sex);

\t\t\t请输入学生的年龄:

age);

\t\t\t请输入学生的地址:

address);

\t\t\t请输入学生的成绩:

%f"

score);

insert(p0);

\t\t\t该学生的信息为:

\n"

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

\t\t\t姓名\t学号\t\t年龄\t性别\t地址\t\t成绩\n"

display(p0);

voidinsert(structstudent*stu)

structstudent*p0,*p1,*p2;

p1=head;

p0=stu;

if(head==NULL)

head=p0;

p0->

next=NULL;

else

while((p0->

num>

p1->

num)&

&

(p1->

next!

=NULL))

p2=p1;

p1=p1->

next;

}

if(p0->

num<

=p1->

num)

if(head==p1)

head=p0;

else

p2->

next=p0;

p0->

next=p1;

p1->

TOTAL_NUM++;

voiddisplay(structstudent*p)

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

p->

name,p->

num,p->

age,p->

sex,p->

address,p->

//浏览学生信息

voiddisplayAll()

structstudent*p;

printf("

\t\t\t学生总数:

%d\n"

TOTAL_NUM);

p=head;

if(head!

=NULL)

printf("

do

display(p);

p=p->

}

while(p!

=NULL);

voidquery()

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

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

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

|取消请按0|\n"

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

scanf("

switch(choice)

return;

query_by_num();

query_by_name();

printf("

while(choice!

//按姓名查询学生信息

voidquery_by_name()

structstudent*p1;

请输入学生的姓名"

scanf("

name);

if(head==NULL)

{printf("

无学生记录\n"

return;

p1=head;

while(strcmp(name,p1->

name)&

next!

=NULL)

p1=p1->

if(!

strcmp(name,p1->

name))

display(p1);

没有该学生记录请核对"

//按学号查询学生信息

voidquery_by_num()

intnum;

请输入学生的学号"

无学生记录\n"

return;

while(num!

=p1->

num&

p1=p1->

if(num==p1->

{

display(p1);

\t\t\t没有该学生记录请核对"

//写入文件

voidwriteData()

FILE*fp;

//文件指针

fp=fopen("

1.txt"

"

w"

if(!

fp)

文件打开错误"

fprintf(fp,"

for(p=head;

p!

=NULL;

p=p->

next)

fprintf(fp,"

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

sex,p->

fclose(fp);

}

voidfreeAll()

structstudent*p1,*p2;

p1=p2=head;

while(p1)

p2=p1->

free(p1);

p1=p2;

}//读取文件

voidreadData()

student.txt"

r"

if(!

文件打开错误"

fscanf(fp,"

TOTAL_NUM);

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

p1->

name,&

p1->

num,p1->

sex,&

age,p1->

address,&

while(!

feof(fp))

p1=(structstudent*)malloc(LEN);

fscanf(fp,"

sex,&

p2->

p2=p1;

p2->

fclose(fp);

//删除学生信息

voiddel()

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

scanf("

p1=head;

while(num!

p2=p1;

p1=p1->

if(num==p1->

if(p1==head)

head=p1->

next=p1->

free(p1);

TOTAL_NUM--;

else

没有该学生记录请核对\n"

voidsort()//排序模块。

将学生记录按学号从小到大排列。

用起泡排序算法实现

{

inti;

structstudent*ptr,*s=head,*p;

intcount=0,count1;

while(s)//统计链表结点个数

count++;

s=s->

}

for(i=1;

i<

count;

i++)

ptr=head;

p=NULL;

count1=count-i;

//用来控制每轮起泡排序的终点即每次把学号最小的结点移到倒数第i个结点

while(ptr&

ptr->

next&

(count1--))

{

if(ptr->

score>

next->

score)

{

s=ptr->

ptr->

next=s->

if(p==NULL)//ptr处于队头时

head=s;

else

p->

next=s;

s->

next=ptr;

p=s;

}

else

ptr=ptr->

p=head;

p=p->

}

displayAll();

voidchange()

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

scanf("

while(num!

if(num==p1->

devise(p1);

voiddevise(structstudent*p)

请选择您要修改的学生的信息内容\n"

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

|姓名请按1|\n"

|学号请按2|\n"

|性别请按3|\n"

|年龄请按4|\n"

|地址请按5|\n"

|爱好请按6|\n"

请输入新姓名"

请输入新学号"

p->

请输入新性别"

请输入新年龄"

请输入新地址"

请输入新成绩"

}

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

当前位置:首页 > 人文社科 > 文化宗教

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2