学生管理系统c语言 学生管理系统C语言项目总结

您好,今天小怡来为大家解答以上的问题。学生管理系统c语言相信很多小伙伴还不知道,现在让我们一起来看看吧!

1、#include#include#include#include#define N 200int input(struct Student stu[N]);void se(struct Student stu[N],int n);int load(struct Student stu[N]);void output(struct Student stu[N],int n);int insert(struct Student stu_se[],int n);void sort(struct Student stu_se[],int n);void find(struct Student stu_se[],int n);int delete_stu(struct Student stu_se[],int n);typedef struct Student{char num[20];char name[20];char ;int age;float score[3];float tolscore;float e;}STU;int main(){int total=0,a;STU stu[N];printf("☆☆☆☆☆学籍管理系统☆☆☆☆☆nn");do{printf("nn");printf("1-导入学生信息n2-加载学生信息n3-保存学生信息n4-按学号插入学生n5-给学生排序n6-查找学生n7-删除学生n8-输出当前n9-退出n");printf("n");printf("请按键选择:");scanf("%d",&a);switch(a){case 1:total=input(stu);break;case 2: total=load(stu);break;case 3:se(stu,total);break;case 4: total+=insert(stu,total);break;case 5:sort(stu,total);break;case 6:find(stu,total);break;case 7:total-=delete_stu(stu,total);break;case 8:output(stu,total);break;case 9:exit(0);break;default:printf("输入错误,请重新输入!n");break;}//("cls");}while(1);}int input(struct Student stu[]){int i,j,n;float sum;printf("请输入要导入的学生人数n");scanf("%d",&n);printf("请输入学生的学号、姓名、性别、年龄及三门课成绩n");for(i=0;i{scanf("%s",stu[i].num);scanf("%s",stu[i].name);scanf(" %c",&stu[i].); //%c前的空格用于接收上一个字符串后的空格、回车、制表符,etcscanf("%d",&stu[i].age);sum=0;for(j=0;j{scanf("%f",&stu[i].score[j]);sum+=stu[i].score[j];}stu[i].tolscore=sum;stu[i].e=sum/3.0f;}return (n);}void se(struct Student stu[],int n){FILE fp;int i;char filename[20];printf("请输入文件名:");scanf("%s",filename);if(strchr(filename,'.')==NULL)strcat(filename,".dat");if((fp=fopen(filename,"wb"))==NULL){printf("Cannot open this filen");("pause");return;}fwrite(&n,sizeof(int),1,fp);for(i=0;ifwrite(&stu[i],sizeof(struct Student),1,fp);fclose(fp);printf("保存成功!");("pause");return;}int load(struct Student stu_se[]){FILE fp;int i,n;char filename[20];printf("请输入要加载的文件名: ");//getchar();scanf("%s",filename);// gets(filename);if(strchr(filename,'.')==NULL)strcat(filename,".dat");if((fp=fopen(filename,"rb"))==NULL){printf("Cannot open this filen");("pause");return 0;}fread(&n,sizeof(int),1,fp);for(i=0;ifread(&stu_se[i],sizeof(struct Student),1,fp);fclose(fp);("cls");printf("文件加载成功!数据如下");output(stu_se,n);return n;}void output(struct Student stu_se[],int n){int i,j;// ("cls");printf("n学号t姓名t性别t年龄t成绩一t成绩二t成绩三t总分t平均分n");for(i=0;i{printf("%st",stu_se[i].num);printf("%st",stu_se[i].name);printf("%ct",stu_se[i].);printf("%dt",stu_se[i].age);for(j=0;jprintf("%gt",stu_se[i].score[j]);printf("%gt",stu_se[i].tolscore);printf("%.2f",stu_se[i].e);putchar(10);}("pause");return;}int insert(struct Student stu_se[],int n){int i,j,num=0;float sum=0;struct Student s;char flag;if(n>200){printf("空间已满,无法插入!n");return 0;}// load(stu_se,n-1);do{printf("n请依次输入学号、姓名、性别、年龄及三门课成绩n");scanf("%s",s.num);scanf("%s",s.name);scanf(" %c",&s.); //%c前的空格用于接收上一个字符串后的空格、回车、制表符,etcscanf("%d",&s.age);for(j=0;jscanf("%f",&s.score[j]);sum=0;for(j=0;jsum+=s.score[j];s.tolscore=sum;s.e=sum/3;num++;for(i=n+num-1;strcmp(stu_se[i-1].num,s.num)>0&&i>0;i--)stu_se[i]=stu_se[i-1];stu_se[i]=s;printf("插入成功!");fflush(stdin);do{printf("继续插入?(y/n)");flag=getch();}while(flag!='y'&&flag!='n');}while(flag=='y');("pause");//se(stu_se,n);return num;}void sort(struct Student stu_se[],int n){int a,i,j;struct Student t;("cls");printf("n1-按序号排序n2-按成绩排序n请选择:");scanf("%d",&a);while(a!=1&&a!=2){printf("输入有误,请重新输入!n");scanf("%d",&a);}//load(stu_se,n);if(a==1){for(i=0;ifor(j=0;j{if(strcmp(stu_se[j].num,stu_se[j+1].num)>0){t=stu_se[j];stu_se[j]=stu_se[j+1];stu_se[j+1]=t;}}}else{for(i=0;ifor(j=0;j{if(stu_se[j].e{t=stu_se[j];stu_se[j]=stu_se[j+1];stu_se[j+1]=t;}}}// se(stu_se,n);printf("排序成功!n");output(stu_se,n);return;}void find(struct Student stu_se[],int n){char ch;do{int i,j,w=1;char search[20];//load(stu_se,n);printf("请输入学生的学号或姓名");scanf("%s",search);for(i=0;i{if(strcmp(stu_se[i].num,search)==0||strcmp(stu_se[i].name,search)==0){printf("查找成功,该学生的信息为:n");printf("%st",stu_se[i].num);printf("%st",stu_se[i].name);printf("%ct",stu_se[i].);printf("%dt",stu_se[i].age);for(j=0;jprintf("%gt",stu_se[i].score[j]);printf("%gt",stu_se[i].tolscore);printf("%.2f",stu_se[i].e);putchar(10);w=0;break;}}if(w)printf("查找失败n");do{printf("n按Y继续查找,按N返回上级菜单n");ch=getch();}while(ch!='y'&&ch!='n');if(ch=='n')return;}while(ch=='y');}int delete_stu(struct Student stu_se[],int n){int i,w=1;char search[20];// load(stu_se,n);printf("n请输入要删除学生的姓名或学号n");scanf("%s",search);for(i=0;iif(strcmp(stu_se[i].num,search)==0||strcmp(stu_se[i].name,search)==0){w=0;break;}if(w){printf("无此学生!n");return 0;}for(;istu_se[i]=stu_se[i+1];printf("删除成功!n");// se(stu_se,n-1);return 1;}之前随便写的 忘了有没有调试 有问题再私信找我 采纳哦~~//这是我以前的课程设计,。

本文到这结束,希望上面文章对大家有所帮助。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 836084111@qq.com,本站将立刻删除。