Advertisement
Masovski

[C# Basics][Loops-HW] 9. Matrix of Numbers

Mar 29th, 2014
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System;
  2.  
  3. class MatrixOfNumbers
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.         bool inRange = n >= 1 && n <= 20;
  9.         if (inRange)
  10.         {
  11.             for (int row = 1; row <= n; row++)
  12.             {
  13.                 for (int column = 0; column < n; column++)
  14.                 {
  15.                     Console.Write(row + column + " ");
  16.                 }
  17.                 Console.WriteLine();
  18.             }
  19.             Console.WriteLine();
  20.         }
  21.         else
  22.         {
  23.             Console.WriteLine("Invalid input. Correct input --> 1 <= n <= 20");
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement