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.
373 lines
6.6 KiB
373 lines
6.6 KiB
#include<stdio.h>
|
|
#include<string.h>
|
|
struct Student
|
|
{
|
|
int num;
|
|
int sclass;
|
|
char name[5];
|
|
float mark1;
|
|
float mark2;
|
|
float mark3;
|
|
};
|
|
struct Student 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}};
|
|
|
|
int main()
|
|
{
|
|
void Sclass(struct Student stu[]);
|
|
void Snum(struct Student stu[]);
|
|
void Sname(struct Student stu[]);
|
|
void Smark(struct Student stu[]);
|
|
void Intergrate(struct Student stu[]);
|
|
struct Student *p=stu;
|
|
char input;
|
|
scanf("%c",&input);
|
|
if(input=='1')
|
|
{
|
|
Sclass(p);
|
|
}
|
|
else if(input=='2')
|
|
{
|
|
Snum(p);
|
|
}
|
|
else if(input=='3')
|
|
{
|
|
Sname(p);
|
|
}
|
|
else if(input=='4')
|
|
{
|
|
Smark(p);
|
|
}
|
|
else if(input=='5')
|
|
{
|
|
Intergrate(p);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void Sclass(struct Student stu[])
|
|
{
|
|
char input[10];
|
|
struct Student slc[7];
|
|
struct Student temp;
|
|
gets(input);
|
|
int i,j,k;
|
|
if(input[3]=='-')
|
|
{
|
|
k=0;
|
|
for(j=0;j<7;j++)
|
|
{
|
|
if((stu[j].sclass>=input[2]-38)&&(stu[j].sclass<=input[5]-38))
|
|
{
|
|
slc[k]=stu[j];
|
|
k++;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
k=0;
|
|
for(j=0;j<7;j++)
|
|
{
|
|
if(stu[j].sclass==input[2]-38)
|
|
{
|
|
slc[k]=stu[j];
|
|
k++;
|
|
}
|
|
}
|
|
}
|
|
for(i=k-1;i>=0;i--)
|
|
{
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(slc[j].sclass>slc[j+1].sclass)
|
|
{
|
|
temp=slc[j];
|
|
slc[j]=slc[j+1];
|
|
slc[j+1]=temp;
|
|
}
|
|
else if(slc[j].sclass==slc[j+1].sclass)
|
|
{
|
|
if((slc[j].mark1+slc[j].mark2+slc[j].mark3)<(slc[j+1].mark1+slc[j+1].mark2+slc[j+1].mark3))
|
|
{
|
|
temp=slc[j];
|
|
slc[j]=slc[j+1];
|
|
slc[j+1]=temp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for(i=0;i<k;i++)
|
|
{
|
|
printf("%d %d %s %.1f %.1f %.1f\n",slc[i].num,slc[i].sclass,slc[i].name,slc[i].mark1,slc[i].mark2,slc[i].mark3);
|
|
}
|
|
}
|
|
|
|
void Snum(struct Student stu[])
|
|
{
|
|
char input[12];
|
|
struct Student slc[7];
|
|
struct Student temp;
|
|
gets(input);
|
|
int i,j,k;
|
|
if(input[6]=='-')
|
|
{
|
|
k=0;
|
|
for(j=0;j<7;j++)
|
|
{
|
|
if((stu[j].num>=10000+input[5]-48)&&(stu[j].num<=10000+input[11]-48))
|
|
{
|
|
slc[k]=stu[j];
|
|
k++;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
k=0;
|
|
for(j=0;j<7;j++)
|
|
{
|
|
if(stu[j].num==10000+input[5]-48)
|
|
{
|
|
slc[k]=stu[j];
|
|
k++;
|
|
}
|
|
}
|
|
}
|
|
for(i=k-1;i>=0;i--)
|
|
{
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(slc[j].sclass>slc[j+1].sclass)
|
|
{
|
|
temp=slc[j];
|
|
slc[j]=slc[j+1];
|
|
slc[j+1]=temp;
|
|
}
|
|
else if(slc[j].sclass==slc[j+1].sclass)
|
|
{
|
|
if((slc[j].mark1+slc[j].mark2+slc[j].mark3)<(slc[j+1].mark1+slc[j+1].mark2+slc[j+1].mark3))
|
|
{
|
|
temp=slc[j];
|
|
slc[j]=slc[j+1];
|
|
slc[j+1]=temp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for(i=0;i<k;i++)
|
|
{
|
|
printf("%d %d %s %.1f %.1f %.1f\n",slc[i].num,slc[i].sclass,slc[i].name,slc[i].mark1,slc[i].mark2,slc[i].mark3);
|
|
}
|
|
}
|
|
|
|
void Sname(struct Student stu[])
|
|
{
|
|
char input[6];
|
|
struct Student slc[7];
|
|
struct Student temp;
|
|
gets(input);
|
|
int i,j,k;
|
|
int m[7];
|
|
for(i=0;i<7;i++)
|
|
{
|
|
slc[i]=stu[i];
|
|
m[i]=0;
|
|
}
|
|
for(i=1;i<6;i++)
|
|
{
|
|
if(input[i]=='*')
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
for(j=1;j<i;j++)
|
|
{
|
|
for(k=0;k<7;k++)
|
|
{
|
|
if(input[j]==stu[k].name[j-1])
|
|
{
|
|
m[k]++;
|
|
}
|
|
}
|
|
}
|
|
k=0;
|
|
for(j=0;j<7;j++)
|
|
{
|
|
if(m[j]==i-1)
|
|
{
|
|
slc[k]=stu[j];
|
|
k++;
|
|
}
|
|
}
|
|
for(i=k-1;i>=0;i--)
|
|
{
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(slc[j].sclass>slc[j+1].sclass)
|
|
{
|
|
temp=slc[j];
|
|
slc[j]=slc[j+1];
|
|
slc[j+1]=temp;
|
|
}
|
|
else if(slc[j].sclass==slc[j+1].sclass)
|
|
{
|
|
if((slc[j].mark1+slc[j].mark2+slc[j].mark3)<(slc[j+1].mark1+slc[j+1].mark2+slc[j+1].mark3))
|
|
{
|
|
temp=slc[j];
|
|
slc[j]=slc[j+1];
|
|
slc[j+1]=temp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for(i=0;i<k;i++)
|
|
{
|
|
printf("%d %d %s %.1f %.1f %.1f\n",slc[i].num,slc[i].sclass,slc[i].name,slc[i].mark1,slc[i].mark2,slc[i].mark3);
|
|
}
|
|
}
|
|
|
|
void Smark(struct Student stu[])
|
|
{
|
|
char input[5];
|
|
struct Student slc[7];
|
|
struct Student temp;
|
|
gets(input);
|
|
int i,j,k=0;
|
|
if(input[3]=='.')
|
|
{
|
|
for(j=0;j<7;j++)
|
|
{
|
|
if((stu[j].mark1+stu[j].mark2+stu[j].mark3)>((input[1]-48)*10+input[2]-48+(input[4]-48)*0.1))
|
|
{
|
|
slc[k]=stu[j];
|
|
k++;
|
|
}
|
|
}
|
|
}
|
|
else if(input[4]=='.')
|
|
{
|
|
for(j=0;j<7;j++)
|
|
{
|
|
if((stu[j].mark1+stu[j].mark2+stu[j].mark3)>((input[1]-48)*100+(input[2]-48)*10+input[3]-48+(input[5]-48)*0.1))
|
|
{
|
|
slc[k]=stu[j];
|
|
k++;
|
|
}
|
|
}
|
|
}
|
|
for(i=k-1;i>=0;i--)
|
|
{
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(slc[j].sclass>slc[j+1].sclass)
|
|
{
|
|
temp=slc[j];
|
|
slc[j]=slc[j+1];
|
|
slc[j+1]=temp;
|
|
}
|
|
else if(slc[j].sclass==slc[j+1].sclass)
|
|
{
|
|
if((slc[j].mark1+slc[j].mark2+slc[j].mark3)<(slc[j+1].mark1+slc[j+1].mark2+slc[j+1].mark3))
|
|
{
|
|
temp=slc[j];
|
|
slc[j]=slc[j+1];
|
|
slc[j+1]=temp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for(i=0;i<k;i++)
|
|
{
|
|
printf("%d %d %s %.1f %.1f %.1f\n",slc[i].num,slc[i].sclass,slc[i].name,slc[i].mark1,slc[i].mark2,slc[i].mark3);
|
|
}
|
|
}
|
|
|
|
void Intergrate(struct Student stu[])
|
|
{
|
|
char input[100];
|
|
struct Student slc[7];
|
|
struct Student temp;
|
|
gets(input);
|
|
int i,j,k;
|
|
for(i=0;i<100;i++)
|
|
{
|
|
if(input[i]=='.')
|
|
{
|
|
k=0;
|
|
for(j=0;j<7;j++)
|
|
{
|
|
if((stu[j].num>=10000+input[i+5]-48)&&(stu[j].num<=10000+input[i+11]-48)&&(stu[j].sclass>=input[i-4]-38)&&(stu[j].sclass<=input[i-1]-38))
|
|
{
|
|
slc[k]=stu[j];
|
|
k++;
|
|
}
|
|
else if((stu[j].num>=10000+input[i+5]-48)&&(stu[j].num<=10000+input[i+11]-48)&&(stu[j].sclass==input[i-1]-38))
|
|
{
|
|
slc[k]=stu[j];
|
|
k++;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
for(i=k-1;i>=0;i--)
|
|
{
|
|
for(j=0;j<i;j++)
|
|
{
|
|
if(slc[j].sclass>slc[j+1].sclass)
|
|
{
|
|
temp=slc[j];
|
|
slc[j]=slc[j+1];
|
|
slc[j+1]=temp;
|
|
}
|
|
else if(slc[j].sclass==slc[j+1].sclass)
|
|
{
|
|
if((slc[j].mark1+slc[j].mark2+slc[j].mark3)<(slc[j+1].mark1+slc[j+1].mark2+slc[j+1].mark3))
|
|
{
|
|
temp=slc[j];
|
|
slc[j]=slc[j+1];
|
|
slc[j+1]=temp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for(i=0;i<k;i++)
|
|
{
|
|
printf("%d %d %s %.1f %.1f %.1f\n",slc[i].num,slc[i].sclass,slc[i].name,slc[i].mark1,slc[i].mark2,slc[i].mark3);
|
|
}
|
|
}
|
|
|
|
/*void step5(void)
|
|
{
|
|
int i,j=-1,k,l;
|
|
char c='a';
|
|
int s;
|
|
int N=3;
|
|
scanf("%d",&s);
|
|
for(i=0;i<N;i++)
|
|
if(strcmp(s,stu[i].num)==0||strcmp(s,stu[i].num)==0)
|
|
{j=i;break;}
|
|
for(k=0;k<N;k++)
|
|
{
|
|
if(k==j)continue;
|
|
else
|
|
{
|
|
printf("%d %d %s %f %f %f\n",stu[k].num,stu[k].sclass,stu[k].name,stu[k].mark1,stu[k].mark2,stu[k].mark3);
|
|
}
|
|
}
|
|
printf("Are you sure?(yes/no)\n");
|
|
while(c)
|
|
{
|
|
scanf("%c",&c);
|
|
if(c=='n')
|
|
{
|
|
for(l=0;l<N;l++)
|
|
printf("%d %d %s %f %f %f\n",stu[l].num,stu[l].sclass,stu[l].name,stu[l].mark1,stu[l].mark2,stu[l].mark3);
|
|
}
|
|
if(c=='y'||c=='n')
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}*/
|