Facebook
From trolle, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 248
  1. package javaapplication6;
  2.  
  3. public class JavaApplication6 {
  4.  
  5.     public static void main(String[] args) {
  6.         int[][] tab = {
  7.             {1, 0, 0},
  8.             {0, 1, 0},
  9.             {0, 0, 1}
  10.         };
  11.         boolean Diagonal = true;
  12.         for (int i = 0; i < tab.length; i++) {
  13.             if(tab.length != tab[i].length){
  14.             Diagonal = false;
  15.             }
  16.                 for (int j = 0; j < tab[i].length; j++) {
  17.                     System.out.print(tab[i][j] + " ");
  18.                     if (j != i && tab[i][j] != 0) {
  19.                         Diagonal = false;
  20.                     }
  21.                 }
  22.                 System.out.println("");
  23.             }
  24.             if (Diagonal) {
  25.                 System.out.println("okay");
  26.             } else {
  27.                 System.out.println("not okay :( ");
  28.             }
  29.         }
  30.     }
  31.  
  32.