You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
176 lines
2.8 KiB
176 lines
2.8 KiB
1 year ago
|
#include <stdio.h>
|
||
|
#include <time.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
void a1();
|
||
|
void a2();
|
||
|
void a3();
|
||
|
void a4();
|
||
|
void a5();
|
||
|
void menu();
|
||
|
int sum=7;
|
||
|
struct stu
|
||
|
{
|
||
|
int Id;
|
||
|
int clas;
|
||
|
char name[100];
|
||
|
float score1;
|
||
|
float score2;
|
||
|
float score3;
|
||
|
float score;
|
||
|
}stu[100]={{10001,11,"Zhang",99.5,88.5,89.5,277.5},
|
||
|
{10002,12,"Yang",77.9,56.5,87.5,221.9},
|
||
|
{10003,11,"Liang",92.5,99.0,60.5,252},
|
||
|
{10004,11,"Cai",89.6,56.9,90.5},
|
||
|
{10005,14,"Fu",55.6,67.9,98.9},
|
||
|
{10006,12,"Mao",22.1,45.9,99.2},
|
||
|
{10007,13,"Zhan",35.6,67.9,88.0}};
|
||
|
int main()
|
||
|
{
|
||
|
while(1)
|
||
|
{
|
||
|
menu();
|
||
|
}
|
||
|
}
|
||
|
void menu()
|
||
|
{
|
||
|
int t;
|
||
|
scanf("%d",&t);
|
||
|
switch(t)
|
||
|
{
|
||
|
case 1:a1();break;
|
||
|
case 2:a2();break;
|
||
|
case 3:a3();break;
|
||
|
case 4:a4();break;
|
||
|
case 5:a5();break;
|
||
|
}
|
||
|
}
|
||
|
void a1()
|
||
|
{
|
||
|
char b[1000];
|
||
|
int x1=0,x2=0,len,i=0;
|
||
|
gets(b);
|
||
|
len=strlen(b);
|
||
|
while(b[i]!='-')
|
||
|
{
|
||
|
i=i+1;
|
||
|
}
|
||
|
for(int j=1;j<i;j++)
|
||
|
{
|
||
|
x1=x1*10+b[j]-'0';
|
||
|
}
|
||
|
for(int j=i+1;j<len;j++)
|
||
|
{
|
||
|
x2=x2*10+b[j]-'0';
|
||
|
}
|
||
|
for(int k=x1;k<=x2;k++)
|
||
|
{
|
||
|
for(int j=0;j<sum;j++)
|
||
|
{
|
||
|
if(stu[j].clas==k)
|
||
|
{
|
||
|
printf("%d %d %s %.1f %.1f %.1f\n",stu[j].Id,stu[j].clas,stu[j].name,stu[j].score1,stu[j].score2,stu[j].score3);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
void a2()
|
||
|
{
|
||
|
char b[1000];
|
||
|
int x1=0,x2=0,len,i=0;
|
||
|
gets(b);
|
||
|
len=strlen(b);
|
||
|
while(b[i]!='-')
|
||
|
{
|
||
|
i=i+1;
|
||
|
}
|
||
|
for(int j=1;j<i;j++)
|
||
|
{
|
||
|
x1=x1*10+b[j]-'0';
|
||
|
}
|
||
|
for(int j=i+1;j<len;j++)
|
||
|
{
|
||
|
x2=x2*10+b[j]-'0';
|
||
|
}
|
||
|
for(int k=x1;k<=x2;k++)
|
||
|
{
|
||
|
for(int j=0;j<sum;j++)
|
||
|
{
|
||
|
if(stu[j].Id==k)
|
||
|
{
|
||
|
printf("%d %d %s %.1f %.1f %.1f\n",stu[j].Id,stu[j].clas,stu[j].name,stu[j].score1,stu[j].score2,stu[j].score3);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
void a3()
|
||
|
{
|
||
|
char b[100];
|
||
|
int len,f;
|
||
|
gets(b);
|
||
|
len=strlen(b)-1;
|
||
|
for(int i=0;i<sum;i++)
|
||
|
{
|
||
|
f=1;
|
||
|
for(int j=1;j<len;j++)
|
||
|
{
|
||
|
if(stu[i].name[j-1]!=b[j])
|
||
|
{
|
||
|
f=0;
|
||
|
}
|
||
|
}
|
||
|
if(f==1)
|
||
|
{
|
||
|
printf("%d %d %s %.1f %.1f %.1f\n",stu[i].Id,stu[i].clas,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
void a4()
|
||
|
{
|
||
|
int a;
|
||
|
scanf("%d",&a);
|
||
|
for(int i=0;i<sum;i++)
|
||
|
{
|
||
|
if(stu[i].score1+stu[i].score2+stu[i].score3>a)printf("%d %d %s %.1f %.1f %.1f\n",stu[i].Id,stu[i].clas,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3);
|
||
|
}
|
||
|
}
|
||
|
void a5()
|
||
|
{
|
||
|
char b[1000];
|
||
|
int x1=0,x2=0,x3=0,len,t,i=0;
|
||
|
gets(b);
|
||
|
len=strlen(b);
|
||
|
while(b[i]!='.')
|
||
|
{
|
||
|
i=i+1;
|
||
|
}
|
||
|
t=i+1;
|
||
|
for(int j=1;j<i;j++)
|
||
|
{
|
||
|
x1=x1*10+b[j]-'0';
|
||
|
}
|
||
|
while(b[i]!='-')
|
||
|
{
|
||
|
i=i+1;
|
||
|
}
|
||
|
for(int j=t;j<i;j++)
|
||
|
{
|
||
|
x2=x2*10+b[j]-'0';
|
||
|
}
|
||
|
for(int j=i+1;j<len;j++)
|
||
|
{
|
||
|
x3=x3*10+b[j]-'0';
|
||
|
}
|
||
|
for(int k=x2;k<=x3;k++)
|
||
|
{
|
||
|
for(int j=0;j<sum;j++)
|
||
|
{
|
||
|
if(stu[j].Id==k&&stu[j].clas==x1)
|
||
|
{
|
||
|
printf("%d %d %s %.1f %.1f %.1f\n",stu[j].Id,stu[j].clas,stu[j].name,stu[j].score1,stu[j].score2,stu[j].score3);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|