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.
54 lines
1.1 KiB
54 lines
1.1 KiB
1 year ago
|
#include<stdio.h>
|
||
|
#include<math.h>
|
||
|
#include<string.h>
|
||
|
#include<stdlib.h>
|
||
|
int main()
|
||
|
{
|
||
|
char data[3][6][20],c[20],d[20];int i,j,k;void paixu(char data[][6][20],int rak[3]);int rak[3];
|
||
|
for(i=0;i<3;i++)
|
||
|
{for(j=0;j<6;j++)
|
||
|
{
|
||
|
scanf("%s",&data[i][j]);
|
||
|
}
|
||
|
}
|
||
|
paixu(data,rak);
|
||
|
|
||
|
scanf("%s",&c);while(getchar() != '\n');
|
||
|
printf("Are you sure(yes/no)?");
|
||
|
scanf("%s",&d);
|
||
|
|
||
|
if(!strcmp(d,"n"))
|
||
|
{
|
||
|
for(i=0;i<3;i++)
|
||
|
{for(j=0;j<6;j++)
|
||
|
{
|
||
|
printf("%s ",data[rak[i]][j]);
|
||
|
}printf("\n");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if(!strcmp(d,"y"))
|
||
|
{for(k=0;k<3;k++){if(strcmp(c,data[k][0])==0){break;};if(strcmp(c,data[k][2])==0){break;};}
|
||
|
for(i=0;i<3;i++)
|
||
|
{for(j=0;j<6;j++)
|
||
|
{
|
||
|
if(rak[i]!=k)printf("%s ",data[rak[i]][j]);
|
||
|
}printf("\n");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void paixu(char data[][6][20],int rak[3])
|
||
|
{
|
||
|
int mark[3]={0,0,0},clas[3];float sum[3];int i,j,k;
|
||
|
for(i=0;i<3;i++){sum[i]=atof(data[i][3])+atof(data[i][4])+atof(data[i][5]);clas[i]=atoi(data[i][1]);}
|
||
|
for(i=0;i<3;i++)
|
||
|
{
|
||
|
for(j=k=0;k<3&&j<3;)
|
||
|
{
|
||
|
if(mark[j]){j++;continue;}if(mark[k]){k++;continue;}
|
||
|
if(clas[k]<clas[j]){j=k;k++;continue;}if(clas[k]==clas[j]&&sum[k]>sum[j]){j=k;k++;continue;}
|
||
|
k++;continue;
|
||
|
}rak[i]=j;mark[j]=1;
|
||
|
}
|
||
|
}
|