该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
/* Note:Your choice is C IDE */
#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
#include "string.h"
struct student
{
int num;
char name[20];
float score1;
float score2;
float average;
};
struct student stu[50];
struct student avg;
int count=0,passwd=123;
int k=0;
void input();
void display();
void sort();
void sort_name();
void sort_score1();
void sort_score2();
void sort_average();
void query();
void query_num();
void query_name();
void update();
void update_num();
void update_name();
void re();
void re_num();
void re_name();
void renew();
void renew_num();
void renew_name();
void pa();
void s();
void main()
{
int p;
system("cls");
printf("\n\n\n\n\n\n\n\t\t\t请输入密码: ");
scanf("%d",&p);
if (p==passwd)
s();
else
{
printf("\n\n\n\n密码输入错误!任意键重新输入!");
getch();
main();
}
}
void s()
{
int select;
system("cls");
printf("----------------学生成绩管理系统----------------\n\n\n");
printf("1.录入\n2.显示\n3.排序\n4.查询\n5.修改\n6.删除\n7.恢复\n8.退出\n\n");
printf("请选择: ");
scanf("%d",&select);
switch(select)
{
case 1:
input();
break;
case 2:
display();
break;
case 3:
sort();
break;
case 4:
query();
break;
case 5:
update();
break;
case 6:
re();
break;
case 7:
renew();
break;
case 8:
break;
default:
printf("选择错误!");
break;
}
}
void input()
{
char select;
system("cls");
printf("学生成绩录入\n\n");
do
{
printf("\n请输入第%d个学生信息\n\n",count+1);
printf("学号: ");
scanf("%d",&stu[count].num);
printf("姓名: ");
scanf("%s",stu[count].name);
printf("成绩一:");
scanf("%f",&stu[count].score1);
printf("成绩二:");
scanf("%f",&stu[count].score2);
stu[count].average=(stu[count].score1+stu[count].score2)/2;
printf("是否继续输入(y/n): ");
fflush(stdin);
select=getchar();
count++;
}while(select=='y'||select=='Y');
if (select=='n'||select=='N')
{
s();
}
}
void display()
{
int i;
system("cls");
printf("学生成绩显示:\n\n");
printf("%-8s%-12s%-12s%-12s%s\n","学号","姓 名","成绩一","成绩二","平均成绩");
printf("%-8s%-12s%-12s%-12s%s\n","====","========","=======","========","========");
for (i=0;i
{
printf("%-8d%-12s%-12.2f%-12.2f%.2f\n",stu[i].num,stu[i].name,stu[i].score1,stu[i].score2,stu[i].average);
}
printf("任意键返回主菜单......");
getch();
s();
}
void sort()
{
int select;
system("cls");
printf("学生成绩排序:\n\n\n");
printf("\n\t\t\t1.按姓名排序\n\t\t\t2.按成绩一排序\n\t\t\t3.按成绩二排序\n\t\t\t4.按平均分排序\n\t\t\t5.返回\n\n");
printf("请选择: ");
scanf("%d",&select);
switch(select)
{
case 1:
sort_name();
break;
case 2:
sort_score1();
break;
case 3:
sort_score2();
break;
case 4:
sort_average();
break;