diff --git a/5.c b/5.c new file mode 100644 index 0000000..86ffe78 --- /dev/null +++ b/5.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include +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]sum[j]){j=k;k++;continue;} +k++;continue; +}rak[i]=j;mark[j]=1; +} +} \ No newline at end of file