NLKappa

hw 15.10.17 keppo

Oct 15th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static boolean isSymm(int[][] arr) {
  6.         for (int i = 2; i < arr.length; i++){
  7.             for (int j = 1; j  < arr.length - 1; j++){
  8.                 if (arr[i][j] != arr[j][i]){
  9.                     return false;
  10.                 } else {
  11.                     return true;
  12.                 }
  13.             }
  14.         }return true;
  15.     }
  16.  
  17.     public static void main(String[] args) {
  18.  
  19.         Scanner sc = new Scanner(System.in);
  20.  
  21.         System.out.print("Введите длину стороны квадрата: ");
  22.         int a = sc.nextInt();
  23.  
  24.         int[][] arr = new int[a][a];
  25.  
  26.         for (int i = 0; i < arr.length; i++) {
  27.  
  28.             for (int j = 0; j < arr[i].length; j++) {
  29.                 System.out.printf("Введите элемент c координатами %d, %d: ", i, j);
  30.                 arr[i][j] = sc.nextInt();
  31.             }
  32.         }
  33.  
  34.         if (isSymm(arr)) {
  35.             System.out.println("Матрица, что вы ввели, симметрична.");
  36.         } else {
  37.             System.out.println("Матрица, что вы ввели НЕ симметрична.");
  38.         }
  39.  
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment