aggressiveviking

16.NumberTable

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