c语言.docx
《c语言.docx》由会员分享,可在线阅读,更多相关《c语言.docx(29页珍藏版)》请在冰豆网上搜索。
c语言
#include"malloc.h"
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
structscorenode
{
intnumber;/*学号*/
charname[10];/*姓名*/
charkcname[10];/*课程名称*/
charbianhao[5];/*课程编号*/
intcredit;/*学分*/
floatphyps;/*大学物理平时成绩*/
floatphysy;/*大学物理实验成绩*/
floatphyjm;/*大学物理卷面成绩*/
floatvfps;/*VF平时成绩*/
floatvfsy;/*VF实验成绩*/
floatvfjm;/*VF卷面成绩*/
floatmathps;/*高等数学平时成绩*/
floatmathsy;/*高等数学实验成绩*/
floatmathjm;/*高等数学卷面成绩*/
}score[7];
structscorenodechange;
structscorenodepaixu[7];
structimformatiom
charsex[10];
intfanghao;
charphone[20];
}imf[7];
floatshifen[7];/*实得学分数组*/
floatzonghe[7];/*综合成绩数组*/
chara[10];
charfilepn[10];/*文件路径以及文件名*/
floatt;
intn;/*录入的学生数*/
intk;
inti;
intj;
intx;
inty;
intu;
intxuehao1;
intxuehao2;
/*全局变量本程序中的函数均可以使用它*/
/*==================================================*/
intcreat()/*录入学生基本信息*/
system("cls");
printf("请输入学生资料,输0退出!
\n");
printf("请输入要输入的学生人数(应为非负数):
");
scanf("%d",&n);
if(n>0)
for(i=0;i{printf("\n\n");printf("请按顺序输入学生学号(学号应大于0):");/*输入学号,学号应大于0*/scanf("%d",&score[i].number);if(score[i].number<0)/*输入学号为字符或小于0时,程序报错,提示重新输入学号*/{printf("输入错误,请重新输入学生学号:");scanf("%d",&score[i].number);}printf("请输入学生姓名:");scanf("%s",&score[i].name);/*输入学生姓名*/printf("请输入大学物理课程编号:");scanf("%s",&score[i].bianhao);printf("请输入该编号的课程名称:");scanf("%s",&score[i].kcname);printf("请输入该科的学分:");scanf("%d",&score[i].credit);printf("请输入大学物理平时成绩(0~100):");scanf("%f",&score[i].phyps);/*输入大学物理平时成绩,成绩应在0-100*/while(score[i].phyps<0||score[i].phyps>100){printf("输入错误,请重新输入大学物理平时成绩");scanf("%f",&score[i].phyps);}/*输入错误,重新输入大学物理平时成绩直到正确为止*/printf("请输入大学物理实验成绩(0~100,无实验则为-1):");scanf("%f",&score[i].physy);/*输入大学物理实验成绩,成绩应在0-100,无实验则为-1*/if(score[i].physy==-1){printf("该科无实验成绩\n");}elsewhile(score[i].physy<0||score[i].physy>100){printf("输入错误,请重新输入大学物理实验成绩");scanf("%f",&score[i].physy);}/*输入错误,重新输入大学物理实验成绩直到正确为止*/printf("请输入大学物理卷面成绩(0~100):");scanf("%f",&score[i].phyjm);/*输入大学物理卷面成绩,成绩应在0-100*/while(score[i].phyjm<0||score[i].phyjm>100){printf("输入错误,请重新输入大学物理卷面成绩");scanf("%f",&score[i].phyjm);}/*输入错误,重新输入大学物理卷面成绩直到正确为止*/printf("请输入VF课程编号:");scanf("%s",&score[i].bianhao);printf("请输入该编号的课程名称:");scanf("%s",&score[i].kcname);printf("请输入该科的学分:");scanf("%d",&score[i].credit);printf("请输入VF平时成绩(0~100):");scanf("%f",&score[i].vfps);/*输入VF平时成绩,成绩应在0-100*/while(score[i].vfps<0||score[i].vfps>100){printf("输入错误,请重新输入VF平时成绩");scanf("%f",&score[i].vfps);}/*输入错误,重新输入VF平时成绩直到正确为止*/printf("请输入VF实验成绩(0~100,无实验则为-1):");scanf("%f",&score[i].vfsy);/*输入VF实验成绩,成绩应在0-100,无实验则为-1*/if(score[i].vfsy==-1){printf("该科无实验成绩\n");}elsewhile(score[i].vfsy<0||score[i].vfsy>100){printf("输入错误,请重新输入VF实验成绩");scanf("%f",&score[i].vfsy);}/*输入错误,重新输入VF实验成绩直到正确为止*/printf("请输入VF卷面成绩(0~100):");scanf("%f",&score[i].vfjm);/*输入VF卷面成绩,成绩应在0-100*/while(score[i].vfjm<0||score[i].vfjm>100){printf("输入错误,请重新输入VF卷面成绩");scanf("%f",&score[i].vfjm);}/*输入错误,重新输入VF卷面成绩直到正确为止*/printf("请输入高等数学课程编号:");scanf("%s",&score[i].bianhao);printf("请输入该编号的课程名称:");scanf("%s",&score[i].kcname);printf("请输入该科的学分:");scanf("%d",&score[i].credit);printf("请输入高等数学平时成绩(0~100):");scanf("%f",&score[i].mathps);/*输入高等数学平时成绩,成绩应在0-100*/while(score[i].mathps<0||score[i].mathps>100){printf("输入错误,请重新输入高等数学平时成绩");scanf("%f",&score[i].mathps);}/*输入错误,重新输入高等数学平时成绩直到正确为止*/printf("请输入高等数学实验成绩(0~100,无实验则为-1):");scanf("%f",&score[i].mathsy);/*输入高等数学实验成绩,成绩应在0-100,无实验则为-1*/if(score[i].mathsy==-1){printf("该科无实验成绩\n");}elsewhile(score[i].mathsy<0||score[i].mathsy>100){printf("输入错误,请重新输入高等数学实验成绩");scanf("%f",&score[i].mathsy);}/*输入错误,重新输入高等数学实验成绩直到正确为止*/printf("请输入高等数学卷面成绩(0~100):");scanf("%f",&score[i].mathjm);/*输入高等数学卷面成绩,成绩应在0-100*/while(score[i].mathjm<0||score[i].mathjm>100){printf("输入错误,请重新输入高等数学卷面成绩");scanf("%f",&score[i].mathjm);}/*输入错误,重新输入高等数学卷面成绩直到正确为止*/}printf("输入学生人数为%d个\n",n);}if(n==0){printf("输入学生人数为0个\n");returnEOF;}system("pause");return0;}/*=================================================================================================*//*=================================================================================================*/intwrite()/*从文件读入学生资料函数*/{intm=0;FILE*fp;system("cls");printf("请输入文件路径及文件名:");scanf("%s",filepn);/*输入文件路径及名称*/if((fp=fopen(filepn,"r+"))==NULL){printf("不能打开文件!\n");return0;}printf("┌──┬────┬──┬────┬─────────┐\n");printf("│学号│姓名│性别│宿舍号码│电话号码│\n");printf("├──┼────┼──┼────┼─────────┤\n");for(i=0;!feof(fp)&&!ferror(fp);i++){fscanf(fp,"%d%s%s%d%s\n",&score[i].number,&score[i].name,&imf[i].sex,&imf[i].fanghao,&imf[i].phone);printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);printf("├──┼────┼──┼────┼─────────┤\n");}/*文件读入与显示*/printf("└──┴────┴──┴────┴─────────┘\n");/*表格下线*/system("pause");fclose(fp);/*结束读入,关闭文件*/return0;}/*=================================================================================================*//*=================================================================================================*//*========================================================================================*/voidsave()/*保存B.txt函数*/{FILE*fp;printf("资料保存到B.txt文件中.\n");if((fp=fopen("B.txt","w"))==NULL){printf("保存出错!\n");exit(0);}for(i=0;i{fprintf(fp,"学号:%d\t姓名:%s\n",score[i].number,score[i].name);fprintf(fp,"课程编号:%s\t课程名称:%s\t平时成绩:%.0f\t实验成绩:%.0f\t卷面成绩:%.0f\n",score[i].bianhao,score[i].kcname,score[i].phyps,score[i].physy,score[i].phyjm);fprintf(fp,"课程编号:%s\t课程名称:%s\t平时成绩:%.0f\t实验成绩:%.0f\t卷面成绩:%.0f\n",score[i].bianhao,score[i].kcname,score[i].vfps,score[i].vfsy,score[i].vfjm);fprintf(fp,"课程编号:%s\t课程名称:%s\t平时成绩:%.0f\t实验成绩:%.0f\t卷面成绩:%.0f\n",score[i].bianhao,score[i].kcname,score[i].mathps,score[i].mathsy,score[i].mathjm);}printf("保存完毕");fclose(fp);system("pause");system("cls");}/*=================================================================================================*//*=================================================================================================*//*========================================================================================*/voidsearch2()/*学生个人信息查询*/{intb;printf("按学号查询请按1\t按姓名查询请按2\n");scanf("%d",&b);switch(b){case1:{printf("请输入一个学号:");scanf("%d",&xuehao2);for(i=0;i{if((xuehao2==score[i].number)&&(xuehao2>0)){u=1;printf("┌──┬────┬──┬────┬─────────┐\n");printf("│学号│姓名│性别│宿舍号码│电话号码│\n");printf("├──┼────┼──┼────┼─────────┤\n");printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);printf("└──┴────┴──┴────┴─────────┘\n");/*表格下线*/}elseu=0;}if(u==0)printf("输入的学号不存在,重新查询");system("pause");};break;case2:{printf("请输入学生姓名:");scanf("%s",a);for(i=0;i{if(strcmp(a,score[i].name)==0)/*strcmp=>字符串比较函数*/{u=1;printf("┌──┬────┬──┬────┬─────────┐\n");printf("│学号│姓名│性别│宿舍号码│电话号码│\n");printf("├──┼────┼──┼────┼─────────┤\n");printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);printf("└──┴────┴──┴────┴─────────┘\n");/*表格下线*/}elseu=0;}system("pause");};break;}}/*========================================================================================*//*========================================================================================*/voidsearch3()/*查询同宿舍学生的信息*/{intsushe;printf("请输入宿舍号码:");scanf("%d",&sushe);for(i=0;i{if((sushe==imf[i].fanghao)&&(sushe>0)){u=1;printf("┌──┬────┬──┬────┬─────────┐\n");printf("│学号│姓名│性别│宿舍号码│电话号码│\n");printf("├──┼────┼──┼────┼─────────┤\n");printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);printf("├──┼────┼──┼────┼─────────┤\n");}elseu=0;}if(u==1){printf("└──┴────┴──┴────┴─────────┘\n");}system("pause");}/*========================================================================================*//*========================================================================================*/voiddel()/*删除函数*/{intxuehaodel;printf("请输入要在A.txt中删除的学生的学号:");scanf("%d",&xuehaodel);for(i=0;i{if(xuehaodel==score[i].number){u=1;for(i=xuehaodel-1;i{score[i]=score[i+1];imf[i]=imf[i+1];}n--;}}}/*========================================================================================*//*========================================================================================*/intmenu(k)/*菜单选择界面函数*/{system("cls");printf("\t\t\t\t学生管理系统\n");printf("\t\t\t作者:戴思途班级:08电气2班学号:3108001054\n\n");printf("\t\t\t");for(i=0;i<15;i++)printf("☆");printf("\n\n");printf("\t\t\t☆1先从文件A.txt中调入资料\n\n\t\t
printf("\n\n");
printf("请按顺序输入学生学号(学号应大于0):
");/*输入学号,学号应大于0*/
scanf("%d",&score[i].number);
if(score[i].number<0)/*输入学号为字符或小于0时,程序报错,提示重新输入学号*/
printf("输入错误,请重新输入学生学号:
}
printf("请输入学生姓名:
scanf("%s",&score[i].name);/*输入学生姓名*/
printf("请输入大学物理课程编号:
scanf("%s",&score[i].bianhao);
printf("请输入该编号的课程名称:
scanf("%s",&score[i].kcname);
printf("请输入该科的学分:
scanf("%d",&score[i].credit);
printf("请输入大学物理平时成绩(0~100):
scanf("%f",&score[i].phyps);/*输入大学物理平时成绩,成绩应在0-100*/
while(score[i].phyps<0||score[i].phyps>100)
printf("输入错误,请重新输入大学物理平时成绩");
scanf("%f",&score[i].phyps);
}/*输入错误,重新输入大学物理平时成绩直到正确为止*/
printf("请输入大学物理实验成绩(0~100,无实验则为-1):
scanf("%f",&score[i].physy);/*输入大学物理实验成绩,成绩应在0-100,无实验则为-1*/
if(score[i].physy==-1)
printf("该科无实验成绩\n");
else
while(score[i].physy<0||score[i].physy>100)
printf("输入错误,请重新输入大学物理实验成绩");
scanf("%f",&score[i].physy);
}/*输入错误,重新输入大学物理实验成绩直到正确为止*/
printf("请输入大学物理卷面成绩(0~100):
scanf("%f",&score[i].phyjm);/*输入大学物理卷面成绩,成绩应在0-100*/
while(score[i].phyjm<0||score[i].phyjm>100)
printf("输入错误,请重新输入大学物理卷面成绩");
scanf("%f",&score[i].phyjm);
}/*输入错误,重新输入大学物理卷面成绩直到正确为止*/
printf("请输入VF课程编号:
printf("请输入VF平时成绩(0~100):
scanf("%f",&score[i].vfps);/*输入VF平时成绩,成绩应在0-100*/
while(score[i].vfps<0||score[i].vfps>100)
printf("输入错误,请重新输入VF平时成绩");
scanf("%f",&score[i].vfps);
}/*输入错误,重新输入VF平时成绩直到正确为止*/
printf("请输入VF实验成绩(0~100,无实验则为-1):
scanf("%f",&score[i].vfsy);/*输入VF实验成绩,成绩应在0-100,无实验则为-1*/
if(score[i].vfsy==-1)
while(score[i].vfsy<0||score[i].vfsy>100)
printf("输入错误,请重新输入VF实验成绩");
scanf("%f",&score[i].vfsy);
}/*输入错误,重新输入VF实验成绩直到正确为止*/
printf("请输入VF卷面成绩(0~100):
scanf("%f",&score[i].vfjm);/*输入VF卷面成绩,成绩应在0-100*/
while(score[i].vfjm<0||score[i].vfjm>100)
printf("输入错误,请重新输入VF卷面成绩");
scanf("%f",&score[i].vfjm);
}/*输入错误,重新输入VF卷面成绩直到正确为止*/
printf("请输入高等数学课程编号:
printf("请输入高等数学平时成绩(0~100):
scanf("%f",&score[i].mathps);/*输入高等数学平时成绩,成绩应在0-100*/
while(score[i].mathps<0||score[i].mathps>100)
printf("输入错误,请重新输入高等数学平时成绩");
scanf("%f",&score[i].mathps);
}/*输入错误,重新输入高等数学平时成绩直到正确为止*/
printf("请输入高等数学实验成绩(0~100,无实验则为-1):
scanf("%f",&score[i].mathsy);/*输入高等数学实验成绩,成绩应在0-100,无实验则为-1*/
if(score[i].mathsy==-1)
while(score[i].mathsy<0||score[i].mathsy>100)
printf("输入错误,请重新输入高等数学实验成绩");
scanf("%f",&score[i].mathsy);
}/*输入错误,重新输入高等数学实验成绩直到正确为止*/
printf("请输入高等数学卷面成绩(0~100):
scanf("%f",&score[i].mathjm);/*输入高等数学卷面成绩,成绩应在0-100*/
while(score[i].mathjm<0||score[i].mathjm>100)
printf("输入错误,请重新输入高等数学卷面成绩");
scanf("%f",&score[i].mathjm);
}/*输入错误,重新输入高等数学卷面成绩直到正确为止*/
printf("输入学生人数为%d个\n",n);
if(n==0)
printf("输入学生人数为0个\n");
returnEOF;
system("pause");
return0;
/*=================================================================================================*/
intwrite()/*从文件读入学生资料函数*/
intm=0;
FILE*fp;
printf("请输入文件路径及文件名:
scanf("%s",filepn);/*输入文件路径及名称*/
if((fp=fopen(filepn,"r+"))==NULL)
printf("不能打开文件!
printf("┌──┬────┬──┬────┬─────────┐\n");
printf("│学号│姓名│性别│宿舍号码│电话号码│\n");
printf("├──┼────┼──┼────┼─────────┤\n");
for(i=0;!
feof(fp)&&!
ferror(fp);i++)
fscanf(fp,"%d%s%s%d%s\n",&score[i].number,&score[i].name,&imf[i].sex,&imf[i].fanghao,&imf[i].phone);
printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);
/*文件读入与显示*/
printf("└──┴────┴──┴────┴─────────┘\n");/*表格下线*/
fclose(fp);/*结束读入,关闭文件*/
/*========================================================================================*/
voidsave()/*保存B.txt函数*/
printf("资料保存到B.txt文件中.\n");
if((fp=fopen("B.txt","w"))==NULL)
printf("保存出错!
exit(0);
for(i=0;i{fprintf(fp,"学号:%d\t姓名:%s\n",score[i].number,score[i].name);fprintf(fp,"课程编号:%s\t课程名称:%s\t平时成绩:%.0f\t实验成绩:%.0f\t卷面成绩:%.0f\n",score[i].bianhao,score[i].kcname,score[i].phyps,score[i].physy,score[i].phyjm);fprintf(fp,"课程编号:%s\t课程名称:%s\t平时成绩:%.0f\t实验成绩:%.0f\t卷面成绩:%.0f\n",score[i].bianhao,score[i].kcname,score[i].vfps,score[i].vfsy,score[i].vfjm);fprintf(fp,"课程编号:%s\t课程名称:%s\t平时成绩:%.0f\t实验成绩:%.0f\t卷面成绩:%.0f\n",score[i].bianhao,score[i].kcname,score[i].mathps,score[i].mathsy,score[i].mathjm);}printf("保存完毕");fclose(fp);system("pause");system("cls");}/*=================================================================================================*//*=================================================================================================*//*========================================================================================*/voidsearch2()/*学生个人信息查询*/{intb;printf("按学号查询请按1\t按姓名查询请按2\n");scanf("%d",&b);switch(b){case1:{printf("请输入一个学号:");scanf("%d",&xuehao2);for(i=0;i{if((xuehao2==score[i].number)&&(xuehao2>0)){u=1;printf("┌──┬────┬──┬────┬─────────┐\n");printf("│学号│姓名│性别│宿舍号码│电话号码│\n");printf("├──┼────┼──┼────┼─────────┤\n");printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);printf("└──┴────┴──┴────┴─────────┘\n");/*表格下线*/}elseu=0;}if(u==0)printf("输入的学号不存在,重新查询");system("pause");};break;case2:{printf("请输入学生姓名:");scanf("%s",a);for(i=0;i{if(strcmp(a,score[i].name)==0)/*strcmp=>字符串比较函数*/{u=1;printf("┌──┬────┬──┬────┬─────────┐\n");printf("│学号│姓名│性别│宿舍号码│电话号码│\n");printf("├──┼────┼──┼────┼─────────┤\n");printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);printf("└──┴────┴──┴────┴─────────┘\n");/*表格下线*/}elseu=0;}system("pause");};break;}}/*========================================================================================*//*========================================================================================*/voidsearch3()/*查询同宿舍学生的信息*/{intsushe;printf("请输入宿舍号码:");scanf("%d",&sushe);for(i=0;i{if((sushe==imf[i].fanghao)&&(sushe>0)){u=1;printf("┌──┬────┬──┬────┬─────────┐\n");printf("│学号│姓名│性别│宿舍号码│电话号码│\n");printf("├──┼────┼──┼────┼─────────┤\n");printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);printf("├──┼────┼──┼────┼─────────┤\n");}elseu=0;}if(u==1){printf("└──┴────┴──┴────┴─────────┘\n");}system("pause");}/*========================================================================================*//*========================================================================================*/voiddel()/*删除函数*/{intxuehaodel;printf("请输入要在A.txt中删除的学生的学号:");scanf("%d",&xuehaodel);for(i=0;i{if(xuehaodel==score[i].number){u=1;for(i=xuehaodel-1;i{score[i]=score[i+1];imf[i]=imf[i+1];}n--;}}}/*========================================================================================*//*========================================================================================*/intmenu(k)/*菜单选择界面函数*/{system("cls");printf("\t\t\t\t学生管理系统\n");printf("\t\t\t作者:戴思途班级:08电气2班学号:3108001054\n\n");printf("\t\t\t");for(i=0;i<15;i++)printf("☆");printf("\n\n");printf("\t\t\t☆1先从文件A.txt中调入资料\n\n\t\t
fprintf(fp,"学号:
%d\t姓名:
%s\n",score[i].number,score[i].name);
fprintf(fp,"课程编号:
%s\t课程名称:
%s\t平时成绩:
%.0f\t实验成绩:
%.0f\t卷面成绩:
%.0f\n",score[i].bianhao,score[i].kcname,score[i].phyps,score[i].physy,score[i].phyjm);
%.0f\n",score[i].bianhao,score[i].kcname,score[i].vfps,score[i].vfsy,score[i].vfjm);
%.0f\n",score[i].bianhao,score[i].kcname,score[i].mathps,score[i].mathsy,score[i].mathjm);
printf("保存完毕");
fclose(fp);
voidsearch2()/*学生个人信息查询*/
intb;
printf("按学号查询请按1\t按姓名查询请按2\n");
scanf("%d",&b);
switch(b)
case1:
printf("请输入一个学号:
scanf("%d",&xuehao2);
for(i=0;i{if((xuehao2==score[i].number)&&(xuehao2>0)){u=1;printf("┌──┬────┬──┬────┬─────────┐\n");printf("│学号│姓名│性别│宿舍号码│电话号码│\n");printf("├──┼────┼──┼────┼─────────┤\n");printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);printf("└──┴────┴──┴────┴─────────┘\n");/*表格下线*/}elseu=0;}if(u==0)printf("输入的学号不存在,重新查询");system("pause");};break;case2:{printf("请输入学生姓名:");scanf("%s",a);for(i=0;i{if(strcmp(a,score[i].name)==0)/*strcmp=>字符串比较函数*/{u=1;printf("┌──┬────┬──┬────┬─────────┐\n");printf("│学号│姓名│性别│宿舍号码│电话号码│\n");printf("├──┼────┼──┼────┼─────────┤\n");printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);printf("└──┴────┴──┴────┴─────────┘\n");/*表格下线*/}elseu=0;}system("pause");};break;}}/*========================================================================================*//*========================================================================================*/voidsearch3()/*查询同宿舍学生的信息*/{intsushe;printf("请输入宿舍号码:");scanf("%d",&sushe);for(i=0;i{if((sushe==imf[i].fanghao)&&(sushe>0)){u=1;printf("┌──┬────┬──┬────┬─────────┐\n");printf("│学号│姓名│性别│宿舍号码│电话号码│\n");printf("├──┼────┼──┼────┼─────────┤\n");printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);printf("├──┼────┼──┼────┼─────────┤\n");}elseu=0;}if(u==1){printf("└──┴────┴──┴────┴─────────┘\n");}system("pause");}/*========================================================================================*//*========================================================================================*/voiddel()/*删除函数*/{intxuehaodel;printf("请输入要在A.txt中删除的学生的学号:");scanf("%d",&xuehaodel);for(i=0;i{if(xuehaodel==score[i].number){u=1;for(i=xuehaodel-1;i{score[i]=score[i+1];imf[i]=imf[i+1];}n--;}}}/*========================================================================================*//*========================================================================================*/intmenu(k)/*菜单选择界面函数*/{system("cls");printf("\t\t\t\t学生管理系统\n");printf("\t\t\t作者:戴思途班级:08电气2班学号:3108001054\n\n");printf("\t\t\t");for(i=0;i<15;i++)printf("☆");printf("\n\n");printf("\t\t\t☆1先从文件A.txt中调入资料\n\n\t\t
if((xuehao2==score[i].number)&&(xuehao2>0))
u=1;
u=0;
if(u==0)
printf("输入的学号不存在,重新查询");
};
break;
case2:
scanf("%s",a);
for(i=0;i{if(strcmp(a,score[i].name)==0)/*strcmp=>字符串比较函数*/{u=1;printf("┌──┬────┬──┬────┬─────────┐\n");printf("│学号│姓名│性别│宿舍号码│电话号码│\n");printf("├──┼────┼──┼────┼─────────┤\n");printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);printf("└──┴────┴──┴────┴─────────┘\n");/*表格下线*/}elseu=0;}system("pause");};break;}}/*========================================================================================*//*========================================================================================*/voidsearch3()/*查询同宿舍学生的信息*/{intsushe;printf("请输入宿舍号码:");scanf("%d",&sushe);for(i=0;i{if((sushe==imf[i].fanghao)&&(sushe>0)){u=1;printf("┌──┬────┬──┬────┬─────────┐\n");printf("│学号│姓名│性别│宿舍号码│电话号码│\n");printf("├──┼────┼──┼────┼─────────┤\n");printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);printf("├──┼────┼──┼────┼─────────┤\n");}elseu=0;}if(u==1){printf("└──┴────┴──┴────┴─────────┘\n");}system("pause");}/*========================================================================================*//*========================================================================================*/voiddel()/*删除函数*/{intxuehaodel;printf("请输入要在A.txt中删除的学生的学号:");scanf("%d",&xuehaodel);for(i=0;i{if(xuehaodel==score[i].number){u=1;for(i=xuehaodel-1;i{score[i]=score[i+1];imf[i]=imf[i+1];}n--;}}}/*========================================================================================*//*========================================================================================*/intmenu(k)/*菜单选择界面函数*/{system("cls");printf("\t\t\t\t学生管理系统\n");printf("\t\t\t作者:戴思途班级:08电气2班学号:3108001054\n\n");printf("\t\t\t");for(i=0;i<15;i++)printf("☆");printf("\n\n");printf("\t\t\t☆1先从文件A.txt中调入资料\n\n\t\t
if(strcmp(a,score[i].name)==0)/*strcmp=>字符串比较函数*/
voidsearch3()/*查询同宿舍学生的信息*/
intsushe;
printf("请输入宿舍号码:
scanf("%d",&sushe);
for(i=0;i{if((sushe==imf[i].fanghao)&&(sushe>0)){u=1;printf("┌──┬────┬──┬────┬─────────┐\n");printf("│学号│姓名│性别│宿舍号码│电话号码│\n");printf("├──┼────┼──┼────┼─────────┤\n");printf("│%d│%s│%s│%d│%s│\n",score[i].number,score[i].name,&imf[i].sex,imf[i].fanghao,imf[i].phone);printf("├──┼────┼──┼────┼─────────┤\n");}elseu=0;}if(u==1){printf("└──┴────┴──┴────┴─────────┘\n");}system("pause");}/*========================================================================================*//*========================================================================================*/voiddel()/*删除函数*/{intxuehaodel;printf("请输入要在A.txt中删除的学生的学号:");scanf("%d",&xuehaodel);for(i=0;i{if(xuehaodel==score[i].number){u=1;for(i=xuehaodel-1;i{score[i]=score[i+1];imf[i]=imf[i+1];}n--;}}}/*========================================================================================*//*========================================================================================*/intmenu(k)/*菜单选择界面函数*/{system("cls");printf("\t\t\t\t学生管理系统\n");printf("\t\t\t作者:戴思途班级:08电气2班学号:3108001054\n\n");printf("\t\t\t");for(i=0;i<15;i++)printf("☆");printf("\n\n");printf("\t\t\t☆1先从文件A.txt中调入资料\n\n\t\t
if((sushe==imf[i].fanghao)&&(sushe>0))
if(u==1)
printf("└──┴────┴──┴────┴─────────┘\n");
voiddel()/*删除函数*/
intxuehaodel;
printf("请输入要在A.txt中删除的学生的学号:
scanf("%d",&xuehaodel);
for(i=0;i{if(xuehaodel==score[i].number){u=1;for(i=xuehaodel-1;i{score[i]=score[i+1];imf[i]=imf[i+1];}n--;}}}/*========================================================================================*//*========================================================================================*/intmenu(k)/*菜单选择界面函数*/{system("cls");printf("\t\t\t\t学生管理系统\n");printf("\t\t\t作者:戴思途班级:08电气2班学号:3108001054\n\n");printf("\t\t\t");for(i=0;i<15;i++)printf("☆");printf("\n\n");printf("\t\t\t☆1先从文件A.txt中调入资料\n\n\t\t
if(xuehaodel==score[i].number)
for(i=xuehaodel-1;i{score[i]=score[i+1];imf[i]=imf[i+1];}n--;}}}/*========================================================================================*//*========================================================================================*/intmenu(k)/*菜单选择界面函数*/{system("cls");printf("\t\t\t\t学生管理系统\n");printf("\t\t\t作者:戴思途班级:08电气2班学号:3108001054\n\n");printf("\t\t\t");for(i=0;i<15;i++)printf("☆");printf("\n\n");printf("\t\t\t☆1先从文件A.txt中调入资料\n\n\t\t
score[i]=score[i+1];
imf[i]=imf[i+1];
n--;
intmenu(k)/*菜单选择界面函数*/
printf("\t\t\t\t学生管理系统\n");
printf("\t\t\t作者:
戴思途班级:
08电气2班学号:
3108001054\n\n");
printf("\t\t\t");
for(i=0;i<15;i++)
printf("☆");
printf("\t\t\t☆1先从文件A.txt中调入资料\n\n\t\t
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1