资源限制
时间限制:1.0s 内存限制:512.0MB
输入一个3行4列的数组,找出该数组中绝对值最大的元素、输出该元素及其两个下标值。如有多个输出行号最小的,还有多个的话输出列号最小的。
样例输入
1 2 3 5
-2 5 8 9
6 -7 5 3
样例输出
9 2 4
————————————————————————————————————————————————
import java.util.Scanner;
public class Main {
static int[][] a = new int[4][5];
static int max = Integer.MIN_VALUE;
static int x;
static int y;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
for(int i = 1;i <= 3;i++) {
for(int j = 1;j <= 4;j++) {
a[i][j] = sc.nextInt();
if(Math.abs(a[i][j]) > max) {
max = Math.abs(a[i][j]);
x = i;
y = j;
}
}
}
sc.close();
System.out.printf("%d %d %d\n", max, x, y);
}
}