Выведите ошибку по языку Java!
Программа запрашивает число N, затем мы создаем двумерный массив N x N и заполняем их числами. Программа должна вывести массив таким образом, как в нижних примерах.



Ввод:

3

0 -2 3

-5 8 -8

1 2 3



Вывод:

x -2 x

-5 x -8

x 2 x

Мое решение:
import java.util.Scanner;
public class Main{
public static void main (String [] args){
Scanner in = new Scanner (System.in);
int n = in.nextInt();
int mass[][] = new int [n][n];
for(int i=0;i for(int j=0;j mass [i][j] = in.nextInt();
}
}
for(int i =0;i for(int j = 0;j if(j>=n-1-i){
System.out.print("x ");
}else{
System.out.print(mass[i][j]+ " ");
}

}
System.out.println();
}
}
}
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Copyright © 2025 SCHOLAR.TIPS - All rights reserved.