#include <stdio.h>
struct student
{
int num;
char name[20];
float chinese;
float maths;
float english;
float physics;
float chemic;
float total;
}; void main (){
int a=0;
struct student stu[5];
scanf ("%d",&a);
switch (a)
{
case 0: printf("请输入功能1、2、3、4、5");
case 1: {
void shuru(struct student);
shuru(stu[5]);
break;
}
case 2:{
void liulan(struct student);
liulan(stu[5]);
break;
} case 3: {
void chaxun(struct student);
chaxun(stu[5]);
break;
}
case 4:{
void tongji(struct student);
tongji(stu[5]);
break;
}
case 5: {
void paixu(struct student);
paixu(stu[5]);
break;
}
}
} void shuru(struct student stu[]){
for (int i=0;i<5 ;i++ )
{
scanf("学号%d 姓名%c 语文%f 数学%f 英语%f 物理%f 化学%f",&stu[i].num,&stu[i].name,&stu[i].chinese,&stu[i].maths,&stu[i].english,&stu[i].physics,&stu[i].chemic);
}
}
void liulan(struct student stu[]){
printf("学号 姓名 语文 数学 英语 物理 化学 ");
for (int i=0;i<5 ;i++)
{
printf("%d %c %f %f %f %f %f",stu[i].num,stu[i].name,stu[i].chinese,stu[i].maths,stu[i].english,stu[i].physics,stu[i].chemic);
}
}
void chaxun(struct student stu[]){
int Num=0;
scanf("查询学号:%d",Num);
for (int i=0;i<5 ;i++)
{
if (Num==stu[i].num)
{
printf("%d %c %f %f %f %f %f",stu[i].num,stu[i].name,stu[i].chinese,stu[i].maths,stu[i].english,stu[i].physics,stu[i].chemic);
}
else printf("请输入正确的学号");
}
}
void tongji(struct student stu[]){
for (int i=0;i<5 ;i++ )
{
stu[i].total=stu[i].num+stu[i].name+stu[i].chinese+stu[i].maths+stu[i].english+stu[i].physics+stu[i].chemic;
}
printf("学号 姓名 语文 数学 英语 物理 化学 总分 ");
for (int i=0;i<5 ;i++)
{
printf("%d %c %f %f %f %f %f %f",stu[i].num,stu[i].name,stu[i].chinese,stu[i].maths,stu[i].english,stu[i].physics,stu[i].chemic,stu[i].total);
} }
void paixu(struct student stu[]){
for (int i=0;i<4 ;i++ )
{
for (int j=i+1;j<5 ;j++ )
{
if (stu[i].total<stu[j].total)
{
int temp=stu[i];
stu[i]=stu[j];
stu[j]=temp;
}
}
}
printf("学号 姓名 语文 数学 英语 物理 化学 总分 ");
for (int i=0;i<5 ;i++)
{
printf("%d %c %f %f %f %f %f %f",stu[i].num,stu[i].name,stu[i].chinese,stu[i].maths,stu[i].english,stu[i].physics,stu[i].chemic,stu[i].total);
}
}
struct student
{
int num;
char name[20];
float chinese;
float maths;
float english;
float physics;
float chemic;
float total;
}; void main (){
int a=0;
struct student stu[5];
scanf ("%d",&a);
switch (a)
{
case 0: printf("请输入功能1、2、3、4、5");
case 1: {
void shuru(struct student);
shuru(stu[5]);
break;
}
case 2:{
void liulan(struct student);
liulan(stu[5]);
break;
} case 3: {
void chaxun(struct student);
chaxun(stu[5]);
break;
}
case 4:{
void tongji(struct student);
tongji(stu[5]);
break;
}
case 5: {
void paixu(struct student);
paixu(stu[5]);
break;
}
}
} void shuru(struct student stu[]){
for (int i=0;i<5 ;i++ )
{
scanf("学号%d 姓名%c 语文%f 数学%f 英语%f 物理%f 化学%f",&stu[i].num,&stu[i].name,&stu[i].chinese,&stu[i].maths,&stu[i].english,&stu[i].physics,&stu[i].chemic);
}
}
void liulan(struct student stu[]){
printf("学号 姓名 语文 数学 英语 物理 化学 ");
for (int i=0;i<5 ;i++)
{
printf("%d %c %f %f %f %f %f",stu[i].num,stu[i].name,stu[i].chinese,stu[i].maths,stu[i].english,stu[i].physics,stu[i].chemic);
}
}
void chaxun(struct student stu[]){
int Num=0;
scanf("查询学号:%d",Num);
for (int i=0;i<5 ;i++)
{
if (Num==stu[i].num)
{
printf("%d %c %f %f %f %f %f",stu[i].num,stu[i].name,stu[i].chinese,stu[i].maths,stu[i].english,stu[i].physics,stu[i].chemic);
}
else printf("请输入正确的学号");
}
}
void tongji(struct student stu[]){
for (int i=0;i<5 ;i++ )
{
stu[i].total=stu[i].num+stu[i].name+stu[i].chinese+stu[i].maths+stu[i].english+stu[i].physics+stu[i].chemic;
}
printf("学号 姓名 语文 数学 英语 物理 化学 总分 ");
for (int i=0;i<5 ;i++)
{
printf("%d %c %f %f %f %f %f %f",stu[i].num,stu[i].name,stu[i].chinese,stu[i].maths,stu[i].english,stu[i].physics,stu[i].chemic,stu[i].total);
} }
void paixu(struct student stu[]){
for (int i=0;i<4 ;i++ )
{
for (int j=i+1;j<5 ;j++ )
{
if (stu[i].total<stu[j].total)
{
int temp=stu[i];
stu[i]=stu[j];
stu[j]=temp;
}
}
}
printf("学号 姓名 语文 数学 英语 物理 化学 总分 ");
for (int i=0;i<5 ;i++)
{
printf("%d %c %f %f %f %f %f %f",stu[i].num,stu[i].name,stu[i].chinese,stu[i].maths,stu[i].english,stu[i].physics,stu[i].chemic,stu[i].total);
}
}
