300行c++代码编程实例?
# include # include # include void select();/*自定义函数*/ void input()的全局声明;void输出();void sort();void search();void modify();void deleted();void save();空载荷();struct student { int numberchar name[9];迷人的性爱;char xy[20];char zy[20];int类;双jcj双pcj双zcj};构造学生a[40];void main(){ select();//调用选择函数} void select(){ int n;系统(“cls”);printf(" |-| \ n ");Printf("|主菜单| \ n ");Printf("| 1。输入函数| \ n ");Printf("| 2。输出函数| \ n ");Printf("| 3。排序函数| \ n ");Printf("| 4。查询函数| \ n ");Printf("| 5。修改函数| \ n ");Printf("| 6。delete function | \ n ");Printf("| 7。保存函数| \ n ");Printf("| 8。LOAD function | \ n ");Printf("| 9。退出程序| \ n ");printf(" |-| \ n ");Printf("请选择一个函数:");scanf("%d ",& ampn);开关(n){ case 1:input();select();打破;/*调用输入函数后,返回主菜单中的函数选择函数*/例2:output();select();打破;案例三:sort();select();打破;案例四:搜索();select();打破;情况五:modify();select();打破;情况6:删除();select();打破;案例7:save();select();打破;情况8:load();select();打破;案例9:出口(0);打破;} getchar();getchar();系统(“暂停”);} void input() { int i,n;系统(“cls”);Printf("欢迎使用输入函数\ n \ n \ n ");for(I = 0;我& lt=39;i++){ printf("-| \ n ");Printf("|是否要输入1学生的信息| \ n ");Printf("| 1。enter | \ n ");Printf("| 2。end input | \ n ");printf("-| \ n ");Printf("请输入您的选择:");scanf("%d ",& ampn);if(n = = 2)break;Printf("学号:");scanf("%d ",& amp甲[我]。号);getchar();printf(" name:");获取(a[i])。姓名);Printf("性别:");甲[我]。sex = getchar();getchar();Printf("学院:");获取(a[i])。xy);Printf("专业:");获取(a[i])。zy);printf(" class:");scanf("%d ",& amp甲[我]。类);Printf("纸张等级:");scanf("%lf ",& amp甲[我]。jcj);Printf("平时成绩:");scanf("%lf ",& amp甲[我]。pcj);} getchar();getchar();系统(“暂停”);} void output(){ int I;系统(“cls”);Printf("欢迎使用输出函数\ n \ n \ n ");Printf("%-9s ","学号");Printf("%-9s ","名称");Printf("%-5s ","性别");Printf("%-20s ","学院");Printf("%-20s ","专业");Printf("%-5s "," class ");Printf("%-9s ","论文成绩");Printf("%-9s ","平时成绩");Printf("%-9s ","总分");printf(" \ n ");for(I = 0;我& lt=39;i++) { a[i]。zcj=a[i]。jcj*0.6+a[i]。pcj如果(a[i]。number = = 0)break;printf("%-9d ",a[i].号);printf("%-9s ",a[i]。姓名);printf("%-5c ",a[i].性);printf("%-20s ",a[i].xy);printf("%-20s ",a[i].zy);printf("%-5d ",a[i].类);printf("%-9.2lf ",a[i].jcj);printf("%-9.2lf ",a[i].pcj);printf("%-9.2lf ",a[i].zcj);printf(" \ n ");} getchar();getchar();系统(“暂停”);} void sort() { int i,j,n;结构学生t;系统(“cls”);Printf("欢迎使用排序函数\ n \ n \ n ");printf("-| \ n ");Printf("|排序菜单| \ n ");Printf("| 1。根据总分从高到低对输出进行排序| \ n ");Printf("| 2。总分降序输出| \ n ");Printf("| 3。退出排序函数| \ n ");printf("-| \ n ");Printf("请输入您的选择:");scanf("%d ",& ampn);开关(n){ case 1:for(j = 38;j & gt=0;j-){ for(I = 0;我& lt= j;i++) { if(a[i]。number == 0 || a[i+1]。number = = 0)break;else { if(a[i].zcj & lta[i+1]。zcj){ t = a[I];a[I]= a[I+1];a[I+1]= t;} } } }破;情况2:for(j = 38;j & gt=0;j-){ for(I = 0;我& lt= j;i++) { if(a[i]。number == 0 || a[i+1]。number = = 0)break;else { if(a[i].zcj & gta[i+1]。zcj){ t = a[I];a[I]= a[I+1];a[I+1]= t;} } } }破;案例三:select();打破;} printf("%-9s ","学号");Printf("%-9s ","名称");Printf("%-5s ","性别");Printf("%-20s ","学院");Printf("%-20s ","专业");Printf("%-5s "," class ");Printf("%-9s ","论文成绩");Printf("%-9s ","平时成绩");Printf("%-9s ","总分");printf(" \ n ");for(I = 0;我& lt=39;i++) { a[i]。zcj=a[i]。jcj*0.6+a[i]。pcj如果(a[i]。number = = 0)break;printf("%-9d ",a[i].号);printf("%-9s ",a[i]。姓名);printf("%-5c ",a[i].性);printf("%-20s ",a[i].xy);printf("%-20s ",a[i].zy);printf("%-5d ",a[i].类);printf("%-9.2lf ",a[i].jcj);printf("%-9.2lf ",a[i].pcj);printf("%-9.2lf ",a[i].zcj);printf(" \ n ");} getchar();getchar();系统(“暂停”);} void search() { int i,n;char search _ name[9];系统(“cls”);Printf("欢迎使用查询函数\ n \ n \ n ");printf("-| \ n ");Printf("|查询菜单| \ n ");Printf("| 1。按姓名查询| \ n ");Printf("| 2。按性别查询| \ n ");Printf("| 3。按学号查询| \ n ");Printf("| 4。按专业查询| \ n ");Printf("| 5。按学院查询| \ n ");Printf("| 6。根据总分查询通过考试的同学| \ n ");Printf("| 7。退出查询功能| \ n ");printf("-| \ n ");Printf("请输入您的选择:");scanf("%d ",& ampn);getchar();switch(n){ case 1:printf(" \ n \ n \ n请输入要查询的同学姓名:");获取(search _ name);Printf("%-9s ","学号");Printf("%-9s ","名称");Printf("%-5s ","性别");Printf("%-20s ","学院");Printf("%-20s ","专业");Printf("%-5s "," class ");Printf("%-9s ","论文成绩");Printf("%-9s ","平时成绩");Printf("%-9s ","总分");printf(" \ n ");for(I = 0;我& lt=39;i++) { if(a[i]。number = = 0)break;else { if(strcmp(a[i])。name,search_name) == 0) { printf("%-9d ",a[i]。号);printf("%-9s ",a[i]。姓名);printf("%-5c ",a[i].性);printf("%-20s ",a[i].xy);printf("%-20s ",a[i].zy);printf("%-5d ",a[i].类);printf("%-9.2lf ",a[i].jcj);printf("%-9.2lf ",a[i].pcj);printf("%-9.2lf ",a[i].zcj);printf(" \ n ");} } }破;案例二:破;} getchar();getchar();系统(“暂停”);} void modify() { int i,n,m;int修改_编号;/*输入修改对象的学号*/system(" cls ");Printf("欢迎修改函数\ n \ n \ n ");printf("-| \ n ");Printf("|修改菜单| \ n ");Printf("| 1。修改所有信息| \ n ");Printf("| 2。修改特定的信息| \ n ");Printf("| 3。退出修改功能| \ n ");printf("-| \ n ");Printf("请输入您的选择:");scanf("%d ",& ampn);getchar();switch(n){ case 1:printf(" \ n \ n请输入您要修改的对象的学号:");scanf("%d ",& ampmodify _ number);for(I = 0;我& lt=39;I++) {if (modify _ number = = a [I]。number) {printf("学号:");scanf("%d ",& amp甲[我]。号);getchar();printf(" name:");获取(a[i])。姓名);Printf("性别:");甲[我]。sex = getchar();getchar();Printf("学院:");获取(a[i])。xy);Printf("专业:");获取(a[i])。zy);