Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static boolean isSymm(int[][] arr) {
- for (int i = 2; i < arr.length; i++){
- for (int j = 1; j < arr.length - 1; j++){
- if (arr[i][j] != arr[j][i]){
- return false;
- } else {
- return true;
- }
- }
- }return true;
- }
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Введите длину стороны квадрата: ");
- int a = sc.nextInt();
- int[][] arr = new int[a][a];
- for (int i = 0; i < arr.length; i++) {
- for (int j = 0; j < arr[i].length; j++) {
- System.out.printf("Введите элемент c координатами %d, %d: ", i, j);
- arr[i][j] = sc.nextInt();
- }
- }
- if (isSymm(arr)) {
- System.out.println("Матрица, что вы ввели, симметрична.");
- } else {
- System.out.println("Матрица, что вы ввели НЕ симметрична.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment