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

上传人:b****6 文档编号:19369568 上传时间:2023-01-05 格式:DOCX 页数:14 大小:16.31KB
下载 相关 举报
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

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

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

//显示所有学生的信息

voidquery();

//查询学生信息

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本程序需要在当前目录下建立才可正常运行\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[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:

\n无效选项!

"

}while(choice!

=0);

//录入学生信息

voidrecord()

structstudent*p0;

p0=(structstudent*)malloc(LEN);

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

%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;

next=NULL;

else

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)

\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;

\t\t\t学生总数:

%d\n"

TOTAL_NUM);

p=head;

if(head!

=NULL)

display(p);

p=p->

while(p!

=NULL);

voidquery()

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

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

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

|取消请按0|\n"

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

return;

query_by_num();

query_by_name();

while(choice!

//按姓名查询学生信息

voidquery_by_name()

structstudent*p1;

请输入学生的姓名"

name);

{printf("

无学生记录\n"

while(strcmp(name,p1->

name)&

if(!

strcmp(name,p1->

name))

display(p1);

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

voidquery_by_num()

intnum;

请输入学生的学号"

无学生记录\n"

while(num!

num&

if(num==p1->

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

//写入文件

voidwriteData()

FILE*fp;

//文件指针

fp=fopen("

"

w"

fp)

文件打开错误"

fprintf(fp,"

for(p=head;

p!

=NULL;

p=p->

next)

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

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->

name,&

num,p1->

sex,&

age,p1->

address,&

while(!

feof(fp))

p1=(structstudent*)malloc(LEN);

voiddel()

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

if(p1==head)

head=p1->

next=p1->

TOTAL_NUM--;

没有该学生记录请核对\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->

next=s->

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

head=s;

p->

next=s;

s->

next=ptr;

p=s;

ptr=ptr->

voidchange()

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

devise(p1);

voiddevise(structstudent*p)

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

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

|姓名请按1|\n"

|学号请按2|\n"

|性别请按3|\n"

|年龄请按4|\n"

|地址请按5|\n"

|爱好请按6|\n"

请输入新姓名"

请输入新学号"

请输入新性别"

请输入新年龄"

请输入新地址"

请输入新成绩"

}

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

当前位置:首页 > 法律文书 > 辩护词

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

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