Advertisement
tchenkov

L07u14_NumberTable

Feb 21st, 2017
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. package Uprajneniq;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /**
  6.  * Created by todor on 21.02.2017 г..
  7.  */
  8. public class u14_NumberTable {
  9.     public static void main(String[] args) {
  10.         Scanner scan = new Scanner(System.in);
  11.         int numSquareSize = Integer.parseInt(scan.nextLine());
  12.    
  13.         for (int i = 1; i <= numSquareSize; i++) {
  14.             for (int j = 0; j < numSquareSize; j++) {
  15.                 int currentNumber = i + j;
  16.                 if (currentNumber > numSquareSize){
  17.                     currentNumber = 2*numSquareSize - currentNumber;
  18.                 }
  19.                 System.out.printf("%d ", currentNumber);
  20.             }
  21.             System.out.println();
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement