import java.util.*;
import java.lang.*;
import java.io.*;
class MatrixApp
{
private static final int X_INIT
= -Integer.
MAX_VALUE;
public static Integer scanInteger
( Scanner in
) {
return ( ( in.hasNextInt() ) ? in.nextInt() : null );
}
public static Double scanDouble
( Scanner in
) {
return ( ( in.hasNextDouble() ) ? in.nextDouble() : null );
}
public static void main
( String[] args
) {
// проверка ввода порядка n
Scanner in
= new Scanner
(System.
in);
int n = scanInteger( in );
if( n <= 0 )
{
System.
out.
printf("error: incomplete input of n\n"); return;
}
if( n <= 1 )
{
System.
out.
printf("error: wrong value of n\n"); return;
}
// создаем массив нужной размерности
double arr[][] = new double[n][n];
// ввод матрицы с проверкой
for( int i = 0; i < n; i++ )
{
for( int j = 0; j < n; j++ )
{
arr[i][j] = scanDouble( in );
}
}
in.close();
// печать введённой матрицы для отладки
System.
out.
printf("input array:\n"); for( int i = 0; i < n; i++ )
{
for( int j = 0; j < n; j++ )
{
System.
out.
printf("\t%2.2f", arr
[i
][j
]); }
}
// вывод результата, содержит номер строки, где необходимо было искать наибольший элемент
System.
out.
printf("result:\n"); for( int i = 0; i < n; i++ )
{
if( arr[i][i] < 0 )
{
double x = arr[i][0];
for( int j = 1; j < n; j++ )
{
if( arr[i][j] > x ) x = arr[i][j];
}
System.
out.
printf("line = %d, max = %2.2f\n", i, x
); }
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CiAKY2xhc3MgTWF0cml4QXBwCnsKICAgcHJpdmF0ZSBzdGF0aWMgZmluYWwgaW50ICBYX0lOSVQgPSAtSW50ZWdlci5NQVhfVkFMVUU7CiAgIAogICBwdWJsaWMgc3RhdGljIEludGVnZXIgc2NhbkludGVnZXIoIFNjYW5uZXIgaW4gKQogICB7CiAgICAgICByZXR1cm4gKCAoIGluLmhhc05leHRJbnQoKSApID8gaW4ubmV4dEludCgpIDogbnVsbCApOwogICB9CiAKICAgcHVibGljIHN0YXRpYyBEb3VibGUgc2NhbkRvdWJsZSggU2Nhbm5lciBpbiApCiAgIHsKICAgICAgIHJldHVybiAoICggaW4uaGFzTmV4dERvdWJsZSgpICkgPyBpbi5uZXh0RG91YmxlKCkgOiBudWxsICk7CiAgIH0KICAgCiAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKCBTdHJpbmdbXSBhcmdzICkKICAgeyAgICAgICAKICAgICAgLy8g0L/RgNC+0LLQtdGA0LrQsCDQstCy0L7QtNCwINC/0L7RgNGP0LTQutCwIG4KICAgICAgU2Nhbm5lciBpbiA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7IAogICAgICAKICAgICAgaW50IG4gPSBzY2FuSW50ZWdlciggaW4gKTsKICAgICAgCiAgICAgIGlmKCBuIDw9IDAgKQogICAgICB7CiAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRmKCJlcnJvcjogaW5jb21wbGV0ZSBpbnB1dCBvZiBuXG4iKTsKICAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIAogICAgICBpZiggbiA8PSAxICkKICAgICAgewogICAgICAgICBTeXN0ZW0ub3V0LnByaW50ZigiZXJyb3I6IHdyb25nIHZhbHVlIG9mIG5cbiIpOwogICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgCiAgICAgIC8vINGB0L7Qt9C00LDQtdC8INC80LDRgdGB0LjQsiDQvdGD0LbQvdC+0Lkg0YDQsNC30LzQtdGA0L3QvtGB0YLQuAogICAgICBkb3VibGUgYXJyW11bXSA9IG5ldyBkb3VibGVbbl1bbl07CgogICAgICAvLyDQstCy0L7QtCDQvNCw0YLRgNC40YbRiyDRgSDQv9GA0L7QstC10YDQutC+0LkKICAgICAgZm9yKCBpbnQgaSA9IDA7IGkgPCBuOyBpKysgKQogICAgICB7CiAgICAgICAgICBmb3IoIGludCBqID0gMDsgaiA8IG47IGorKyApCiAgICAgICAgIHsKICAgICAgICAgICBhcnJbaV1bal0gPSBzY2FuRG91YmxlKCBpbiApOwogICAgICAgIH0gICAgICAKICAgICAgfQogICAgICAKICAgICAgaW4uY2xvc2UoKTsKICAgICAgCiAgICAgIC8vINC/0LXRh9Cw0YLRjCDQstCy0LXQtNGR0L3QvdC+0Lkg0LzQsNGC0YDQuNGG0Ysg0LTQu9GPINC+0YLQu9Cw0LTQutC4CiAgICAgIFN5c3RlbS5vdXQucHJpbnRmKCJpbnB1dCBhcnJheTpcbiIpOwogICAgICBmb3IoIGludCBpID0gMDsgaSA8IG47IGkrKyApCiAgICAgIHsKICAgICAgICAgZm9yKCBpbnQgaiA9IDA7IGogPCBuOyBqKysgKQogICAgICAgICB7CiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRmKCJcdCUyLjJmIiwgYXJyW2ldW2pdKTsgICAgICAgIAogICAgICAgICB9IAogICAgICAgICBTeXN0ZW0ub3V0LnByaW50ZigiXG4iKTsgICAKICAgICAgfQoKICAgICAgLy8g0LLRi9Cy0L7QtCDRgNC10LfRg9C70YzRgtCw0YLQsCwg0YHQvtC00LXRgNC20LjRgiDQvdC+0LzQtdGAINGB0YLRgNC+0LrQuCwg0LPQtNC1INC90LXQvtCx0YXQvtC00LjQvNC+INCx0YvQu9C+INC40YHQutCw0YLRjCDQvdCw0LjQsdC+0LvRjNGI0LjQuSDRjdC70LXQvNC10L3RggogICAgICBTeXN0ZW0ub3V0LnByaW50ZigicmVzdWx0OlxuIik7CiAgICAgIGZvciggaW50IGkgPSAwOyBpIDwgbjsgaSsrICkKICAgICAgIHsKICAgICAgICAgaWYoIGFycltpXVtpXSA8IDAgKQogICAgICAgICB7CiAgICAgICAgICAgIGRvdWJsZSB4ID0gYXJyW2ldWzBdOyAKICAgICAgICAgICAgZm9yKCBpbnQgaiA9IDE7IGogPCBuOyBqKysgKQogICAgICAgICAgICB7ICAgCiAgICAgICAgICAgICAgIGlmKCBhcnJbaV1bal0gPiB4ICkgeCA9IGFycltpXVtqXTsgICAgICAgICAgICAgCiAgICAgICAgICAgIH0KICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGYoImxpbmUgPSAlZCwgbWF4ID0gJTIuMmZcbiIsIGksIHgpOyAKICAgICAgICAgIH0gIAogICAgICAgfQogCiAgIAogICB9Cn0=