学生信息管理系统C语言实现.docx
- 文档编号:8242213
- 上传时间:2023-01-30
- 格式:DOCX
- 页数:16
- 大小:17.74KB
学生信息管理系统C语言实现.docx
《学生信息管理系统C语言实现.docx》由会员分享,可在线阅读,更多相关《学生信息管理系统C语言实现.docx(16页珍藏版)》请在冰豆网上搜索。
学生信息管理系统C语言实现
#include
#include
#include
intinput(structstudcode**);//输入学生信息的函数
voidinstruct(void);//打印提示信息
voidpicture();//制表函数
voidoutput(structstudcode*);//输出函数
voidsearch(structstudcode*);//查找信息函数
intincrease(structstudcode*);//增加学生信息的函数
voiddele(structstudcode**);//删除学生记录的函数
voidprintall(structstudcode*);//输出全部学生信息的函数
voidaverage(structstudcode*headp,structanalysis**head);//统计各科目平均分
intsort(structanalysis**head);//排序函数(升序排列)
voiddate_load(structstudcode**headp);//程序开始载入信息
voiddate_save(structstudcode*headp);//程序结束保存数据
structanalysis
{
charname_ex[20];//实验名称
intnumber;//统计到课人数
floataver;//平均分
structanalysis*next;
};
structstudent
{
charname_tea[20];//教师名字
charname_stu[20];//学生名字
charclas[20];//班级
charname_ex[20];//实验名称
floatmatch;//分数
};
structstudcode
{
structstudentdate;
structstudcode*next;//建立链表的指针
};
intmain()
{
charchoose;
structstudcode*head=NULL;
structanalysis*head1=NULL;
//date_load(&head);
instruct();
printf("\n请选择功能:
");
choose=getchar();
while(choose!
='0')//输入0结束程序
{
switch(choose)
{
case'1':
input(&head);//建立链表
getchar();
getchar();
break;
case'2':
search(head);//查找信息
getchar();
getchar();
break;
case'3':
dele(&head);//删除信息
getchar();
getchar();
break;
case'4':
increase(head);//增加信息
getchar();
getchar();
break;
case'5':
printall(head);//输出全部信息
getchar();
getchar();
break;
case'6':
average(head,&head1);//统计各科平均分并升序输出
getchar();
getchar();
break;
default:
printf("\n选择错误,重选\n");
}
instruct();
printf("\n请选择功能:
");
choose=getchar();
}
system("cls");
date_save(head);
printf("谢谢使用本系统\n");
return0;
}
voidinstruct(void)
{
system("cls");
printf("\n\t\t\t试验管理系统\t\t\t\t");
printf("\n\t\t\t1建立学生信息链表\t\t\t\t");
printf("\n\t\t\t2搜索学生相关信息\t\t\t\t");
printf("\n\t\t\t3删除某个学生信息\t\t\t\t");
printf("\n\t\t\t4增加某个学生信息\t\t\t\t");
printf("\n\t\t\t5输出链表全部信息\t\t\t\t");
printf("\n\t\t\t6统计各科目平均分\t\t\t\t");
printf("\n\t\t\t0退出程序\t\t\t\t");
}
intinput(structstudcode**headp)
{
structstudcode*p,*tail;
chara[4];
system("cls");
date_load(headp);
if(*headp!
=NULL)
{
printf("链表信息载入成功");
return1;
}
else
{
printf("目前没有数据保存请从终端输入数据");
}
printf("\n\t\t\t成绩输入功能\t\t\t\t");
p=(structstudcode*)malloc(sizeof(structstudcode));
if(p==NULL)
{
printf("error");
exit(-1);
}
printf("\n请按提示输入相关信息");
printf("\n教师姓名:
");
scanf("%s",p->date.name_tea);
printf("学生姓名:
");
scanf("%s",p->date.name_stu);
printf("学生班级:
");
scanf("%s",p->date.clas);
printf("实验名称:
");
scanf("%s",p->date.name_ex);
printf("评分:
");
scanf("%f",&p->date.match);
p->next=*headp;
*headp=p;
tail=p;
printf("是否继续输入输入NO退回主菜单其他任意字符继续当前操作\\\\");
scanf("%s",a);
while(strcmp(a,"NO")!
=0)
{
system("cls");
printf("\n\t\t\t成绩输入功能\t\t\t\t");
p=(structstudcode*)malloc(sizeof(structstudcode));
if(p==NULL)
{
printf("error");
exit(-1);
}
printf("\n教师姓名:
");
scanf("%s",p->date.name_tea);
printf("学生姓名:
");
scanf("%s",p->date.name_stu);
printf("学生班级:
");
scanf("%s",p->date.clas);
printf("实验名称:
");
scanf("%s",p->date.name_ex);
printf("评分:
");
scanf("%f",&p->date.match);
p->next=NULL;
tail->next=p;
tail=p;
printf("是否继续输入输入NO退回主菜单其他任意字符继续当前操作\\\\");
scanf("%s",a);
}
return1;
}
voidsearch(structstudcode*headp)
{
intflag=1;
chara[2][20],b[4]="YES";
structstudcode*p;
system("cls");
printf("\n┃\t\t\t成绩查询功能\t\t\t\t");
while(!
strcmp(b,"YES"))
{
p=headp;
printf("\n学生姓名:
");
scanf("%s",a[0]);
printf("实验名称:
");
scanf("%s",a[1]);
for(;p!
=NULL;p=p->next)
{
flag=1;
if(strcmp(a[0],p->date.name_stu)==0&&strcmp(a[1],p->date.name_ex)==0)
{
flag=0;
picture();
output(p);
break;
}
}
if(flag==1)
{
printf("\n请确认您输入的姓名或者实验名称是否正确");
}
printf("\n是否要继续使用该功能YES/NO\\\\");
scanf("%s",b);
system("cls");
printf("\n\t\t\t成绩查询功能\t\t\t\t");
}
}
voidpicture()
{
printf("\t\t\t实验成绩表");
printf("\n教师姓名学生姓名学生班级实验名称实验成绩");
}
voidoutput(structstudcode*p)
{
printf("\n%14s%13s%8s%19s%8.2f",p->date.name_tea,p->date.name_stu,p->date.clas,p->date.name_ex,p->date.match);
}
voiddele(structstudcode**headp)
{
structstudcode*p,*last;
chara[20],b[20],c[5]="YES";
system("cls");
while(strcmp(c,"YES")==0)
{
printf("学生姓名");
scanf("%s",a);
printf("实验名称");
scanf("%s",b);
p=*headp;
while(strcmp(a,p->date.name_stu)!
=0&&strcmp(b,p->date.name_ex)!
=0&&p->next!
=NULL)
{
last=p;
p=p->next;
}
if(strcmp(a,p->date.name_stu)==0&&strcmp(b,p->date.name_ex)==0)
{
if(p==*headp)
*headp=p->next;
else
last->next=p->next;
free(p);
}
else
{
printf("请确认您输入的姓名或者实验名称是否正确");
}
printf("输入YES继续使用该功能,输入其他任意字符退回主菜单\\\\");
scanf("%s",c);
system("cls");
}
}
voidprintall(structstudcode*headp)
{
chara[5];
system("cls");
picture();
if(headp!
=NULL)
{
output(headp);
headp=headp->next;
}
while(headp!
=NULL)
{
output(headp);
headp=headp->next;
}
printf("\n输入back返回主菜单");
while(strcmp(a,"back")!
=0)
scanf("%s",a);
}
voidaverage(structstudcode*headp,structanalysis**head)
{
chara[5];
structanalysis*p=*head;
system("cls");
if(headp==NULL)
{
printf("请先建立链表");
exit(-1);
}
p=*head;
while(p!
=NULL)
{
p->aver=0;
p=p->next;
}
p=*head;
while(headp!
=NULL)
{
while(strcmp(headp->date.name_ex,p->name_ex)!
=0)
{
p=p->next;
}
p->aver+=headp->date.match;
p=*head;
headp=headp->next;
}
while(p!
=NULL)
{
p->aver/=p->number;
p=p->next;
}
p=*head;
sort(head);//求出平均值后排序
while(p!
=NULL)
{
printf("%s平均分为%f\n",p->name_ex,p->aver);
p=p->next;
}
printf("输入back退回主菜单");
scanf("%s",a);
while(strcmp(a,"back"))
{
scanf("%s",a);
}
}
intsort(structanalysis**head)
{
intn=0,i,m,temp1;
floattemp2;
structanalysis*p,*j;
chartemp3[20];
p=*head;
j=p->next;
if(j==NULL)
return0;//如果只有一个科目的数据则不排序
while(p!
=NULL)//统计有几个科目,作为下面冒泡排序控制条件的依据
{
n+=1;
p=p->next;
}
p=*head;
for(i=0;i for(m=0,j=p->next;m { if(p->aver>j->aver)//排序时直接交换各节点数据 { strcpy(temp3,p->name_ex);//交换实验名称 strcpy(p->name_ex,j->name_ex); strcpy(j->name_ex,temp3); temp1=p->number;//交换到课人数 p->number=j->number; j->number=temp1; temp2=p->aver; p->aver=j->aver; j->aver=temp2; } p=j; j=j->next; } return1; } voiddate_load(structstudcode**headp) { charch; FILE*f; structstudcode*p,*tail; if((f=fopen("e: \\input.txt","a+"))==NULL) { printf("error"); exit(0); } ch=fgetc(f);//读取第一个空格,控制格式 if(ch! =EOF)//如果文件中有保存的信息则读取 { if((p=(structstudcode*)malloc(sizeof(structstudcode)))==NULL) { printf("error"); exit(0); } fscanf(f,"%s%s%s%s%f\n",p->date.name_tea,p->date.name_stu,p->date.clas,p->date.name_ex,&p->date.match); p->next=NULL; *headp=p; tail=p; while(! feof(f)) { if((p=(structstudcode*)malloc(sizeof(structstudcode)))==NULL) { printf("error"); exit(0); } fscanf(f,"%s%s%s%s%f\n",p->date.name_tea,p->date.name_stu,p->date.clas,p->date.name_ex,&p->date.match); p->next=NULL; tail->next=p; tail=p; } } fclose(f); } voiddate_save(structstudcode*headp) { FILE*f; structstudcode*p; inti; printf("是否要更新原有数据。 输入1进行更新,其他数字跳过更新步骤: "); scanf("%d",&i); if(i==1)//跟新数据的模块 { if((f=fopen("e: \\input.txt","w"))==NULL) { printf("error"); exit(0); } p=headp; while(p! =NULL) { fprintf(f,"%s%s%s%s%f\n",p->date.name_tea,p->date.name_stu,p->date.clas,p->date.name_ex,p->date.match); p=p->next; } fclose(f); } } intincrease(structstudcode*headp) { chara[4]="YES"; structstudcode*p; system("cls"); if(headp==NULL) { printf("请先创建链表"); return1; } while(headp->next! =NULL) headp=headp->next; while(strcmp(a,"YES")==0) { if((p=(structstudcode*)malloc(sizeof(structstudcode)))==NULL) { printf("error"); exit (1); } printf("教师姓名: "); scanf("%s",p->date.name_tea); printf("学生姓名: "); scanf("%s",p->date.name_stu); printf("学生班级: "); scanf("%s",p->date.clas); printf("实验名称: "); scanf("%s",p->date.name_ex); printf("评分: "); scanf("%f",&p->date.match); p->next=NULL; headp->next=p; headp=p; printf("是否继续增加记录输入YES继续增加,输入其他任意字符退回主菜单"); scanf("%s",a); system("cls"); } return1; }
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 学生 信息管理 系统 语言 实现
![提示](https://static.bdocx.com/images/bang_tan.gif)