[Java]
/* (Start of program header annotation) </p> <p> * copyright and version Declaration of the program
* Copyright (c) 2011, a student from the computer College of Yantai University
* Author: Li Zhaoqing
* Completion date: January 1, September 17, 2012
* Input description:
* Problem description and output: compile a Java application,
* Function: You can call the element with the largest median value in a two-dimensional array to the element in the upper left corner. Then, you can call the element with the smallest value to the element in the lower right corner. For example:
1 4 5 6
7 2 10 11
9 8 12 3,
Reconciliation result
12 4 5 6
7 2 10 11
9 8 3 1
* End the comment in the program Header
*/
Public class Num {
/**
* @ Param args
*/
Public static void main (String [] args ){
Int [] [] a = {1, 4, 5, 6}, {7, 2, 10, 11}, {8, 9, 12, 3 }};
System. out. println ("pre-tuning output array :");
PrintMatrix (a); // outputs an array in two-dimensional mode
System. out. println ("the output array after callback is :");
PrintNewMatrix (a); // The output array after reconciliation
}
// Outputs an array in two-dimensional mode
Static void printMatrix (int [] [] ){
For (int I = 0; I <3; I ++ ){
For (int j = 0; j <4; j ++ ){
System. out. print (a [I] [j] + "");
}
System. out. println ();
}
}
// Output array after reconciliation
Static void printNewMatrix (int [] [] ){
Int t, x;
T = a [2] [3];
A [2] [3] = a [2] [2];
A [2] [2] = t;
X = a [0] [0];
A [0] [0] = a [2] [3];
A [2] [3] = x;
For (int I = 0; I <3; I ++ ){
For (int j = 0; j <4; j ++ ){
System. out. print (a [I] [j] + "");
}
System. out. println ();
}
}
}