pavlinpetkov88

Number Table

Nov 28th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.52 KB | None | 0 0
  1. using System;
  2.  
  3. class NumberTable
  4. {
  5.     static void Main()
  6.     {
  7.  
  8.         int n = int.Parse(Console.ReadLine());
  9.  
  10.         int num = 0;
  11.  
  12.         for (int row = 0; row < n; row++)
  13.         {
  14.             for (int col = 0; col < n; col++)
  15.             {
  16.                 num = row + col + 1;
  17.                 if (num > n)
  18.                 {
  19.                     num = 2 * n - num;
  20.  
  21.                 }
  22.                 Console.Write(num + " ");
  23.             }
  24.             Console.WriteLine();
  25.         }
  26.        
  27.     }
  28. }
Add Comment
Please, Sign In to add comment