Advertisement
marking2112

12. Number Table

Jul 16th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P10_cookieFactory {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scanner.nextLine());
  8.         int num = 0;
  9.  
  10.         for (int row = 0; row < n; row++) {
  11.             for (int col = 0; col < n; col++) {
  12.                 num = row + col + 1;
  13.                 if (num > n) {
  14.                     num = 2 * n - num;
  15.                 }
  16.                 System.out.print(num + " ");
  17.             }
  18.             System.out.println();
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement