#include <stdio.h> int outPutData[2][5]; void judgeMaxTwo(int a, int b, int c, int d, int col) { int temp = 0; int array[4] = {a, b, c, d}; for (int i = 0; i < 3; i++) { for (int j = 0; j < 4 - i - 1; j++) { if (array[j] > array[j + 1]) { temp = array[j + 1]; array[j + 1] = array[j]; array[j] = temp; } } } int max2 = array[3], max1=array[2]; int index1 = -1, index2 = -1; int array2[4] = {a, b, c, d}; for (int i = 0; i < 4; i++) { if (array2[i] == max1) { index1 = i; break; } } for (int i = 0; i < 4; i++) { if (array2[i] == max2&&i!=index1) { index2 = i; break; } } if(index1<index2){ outPutData[0][col]=array2[index1]; outPutData[1][col]=array2[index2]; }else{ outPutData[0][col]=array2[index2]; outPutData[1][col]=array2[index1]; } } int main() { int i, j, cnt = 0; int data[4][5]; while (scanf("%d %d %d %d %d", &data[cnt][0], &data[cnt][1], &data[cnt][2], &data[cnt][3], &data[cnt][4]) != EOF) { // 注意 while 处理多个 case cnt++; scanf("%d %d %d %d %d", &data[cnt][0], &data[cnt][1], &data[cnt][2], &data[cnt][3], &data[cnt][4]); cnt++; scanf("%d %d %d %d %d", &data[cnt][0], &data[cnt][1], &data[cnt][2], &data[cnt][3], &data[cnt][4]); cnt++; scanf("%d %d %d %d %d", &data[cnt][0], &data[cnt][1], &data[cnt][2], &data[cnt][3], &data[cnt][4]); //测试输出数组 // for(i=0;i<4;i++){ // for(j=0;j<5;j++){ // printf("%d ",data[i][j]); // } // printf("\n"); // } for (i = 0; i < 5; i++) { judgeMaxTwo(data[0][i], data[1][i], data[2][i], data[3][i], i); } for (i = 0; i < 2; i++) { for (j = 0; j < 5; j++) { printf("%d ", outPutData[i][j]); } printf("\n"); } } return 0; }