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.
133 lines
2.3 KiB
133 lines
2.3 KiB
1 year ago
|
#include<stdio.h>
|
||
|
#include<string.h>
|
||
|
struct data
|
||
|
{
|
||
|
long int num;
|
||
|
long int clas;
|
||
|
char name[20];
|
||
|
float grade1;
|
||
|
float grade2;
|
||
|
float grade3;
|
||
|
};
|
||
|
struct data stu[7]={10001,11,"Zhang",99.5,88.5,89.5,
|
||
|
10002,12,"Yang",77.9,56.5,87.5,
|
||
|
10003,11,"Liang",92.5,99.0,60.5,
|
||
|
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};
|
||
|
struct data stud;
|
||
|
int main()
|
||
|
{
|
||
|
void sort();
|
||
|
void print(struct data a);
|
||
|
sort();
|
||
|
int t;
|
||
|
scanf("%d",&t);
|
||
|
if(t==1)
|
||
|
{
|
||
|
printf("请输入 班级-班级\n");
|
||
|
int clas1,clas2;
|
||
|
scanf("%ld-%ld",&clas1,&clas2);
|
||
|
for(int i=0;i<7;i++)
|
||
|
{
|
||
|
if(stu[i].clas>=clas1&&stu[i].clas<=clas2)
|
||
|
{
|
||
|
print(stu[i]);
|
||
|
printf("\n");}
|
||
|
}
|
||
|
}
|
||
|
if(t==2)
|
||
|
{
|
||
|
int num1,num2;
|
||
|
printf("请输入 学号-学号\n");
|
||
|
scanf("%ld-%ld",&num1,&num2);
|
||
|
for(int i=0;i<7;i++)
|
||
|
{
|
||
|
if(stu[i].num>=num1&&stu[i].num<=num2)
|
||
|
{
|
||
|
print(stu[i]);
|
||
|
printf("\n");}
|
||
|
}
|
||
|
}
|
||
|
if(t==3)
|
||
|
{
|
||
|
printf("请输入要查询的人名开头几个字母\n");
|
||
|
char nam[10];int len;
|
||
|
scanf("%s",nam);
|
||
|
len=strlen(nam);
|
||
|
for(int i=0;i<7;i++)
|
||
|
{
|
||
|
int k=1;
|
||
|
for(int j=0;j<len;j++)
|
||
|
{
|
||
|
if(nam[j]!=stu[i].name[j])
|
||
|
k=0;
|
||
|
}
|
||
|
if(k==1)
|
||
|
{
|
||
|
print(stu[i]);
|
||
|
printf("\n");}
|
||
|
}
|
||
|
}
|
||
|
if(t==4)
|
||
|
{
|
||
|
printf("请输入要查询的分数\n");
|
||
|
long int score;
|
||
|
scanf("%ld",&score);
|
||
|
for(int i=0;i<7;i++)
|
||
|
{
|
||
|
if((stu[i].grade1+stu[i].grade2+stu[i].grade3)>=score)
|
||
|
{
|
||
|
print(stu[i]);
|
||
|
printf("\n");}
|
||
|
}
|
||
|
}
|
||
|
if(t==5)
|
||
|
{
|
||
|
printf("请输入 班级.学号-学号\n");
|
||
|
int cla,nu1,nu2;
|
||
|
scanf("%ld.%ld-%ld",&cla,&nu1,&nu2);
|
||
|
for(int i=0;i<7;i++)
|
||
|
{
|
||
|
if(stu[i].clas==cla&&stu[i].num>=nu1&&stu[i].num<=nu2)
|
||
|
{
|
||
|
print(stu[i]);
|
||
|
printf("\n");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
void sort()
|
||
|
{
|
||
|
struct data temp;
|
||
|
for(int i=0;i<7;i++)
|
||
|
{
|
||
|
for(int j=i+1;j<7;j++)
|
||
|
{
|
||
|
if(stu[i].clas>stu[j].clas)
|
||
|
{
|
||
|
temp=stu[i];
|
||
|
stu[i]=stu[j];
|
||
|
stu[j]=temp;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
for(int i=0;i<7;i++)
|
||
|
{
|
||
|
for(int j=i+1;j<7;j++)
|
||
|
{
|
||
|
if(stu[i].num>stu[j].num&&stu[i].clas==stu[j].clas)
|
||
|
{
|
||
|
temp=stu[i];
|
||
|
stu[i]=stu[j];
|
||
|
stu[j]=temp;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
void print(struct data a)
|
||
|
{
|
||
|
printf("%ld %ld %s %3.1f %3.1f %3.1f",a.num,a.clas,a.name,a.grade1,a.grade2,a.grade3);
|
||
|
}
|