Advertisement
dimipan80

6.9Loops_PrintMatrixOfNumbers

Mar 24th, 2014
1,225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2.  
  3. class MatrixOfNumbers
  4. {
  5.     static void Main ()
  6.     {
  7.         Console.Write("Please, enter a whole positive number in the range [1...20], N = ");
  8.         string numberStr = Console.ReadLine();
  9.         int numN = int.Parse(numberStr);
  10.         if (numN < 1 || numN > 20)
  11.         {
  12.             Console.WriteLine("Error - Invalid Number !!!");
  13.         }
  14.         else
  15.         {
  16.             Console.WriteLine("The matrix of numbers is:");
  17.             Console.WriteLine();
  18.             for (int i = 1; i <= numN; i++)
  19.             {
  20.                 for (int j = i; j < numN + i; j++)
  21.                 {
  22.                     Console.Write("{0,2} ", j);
  23.                 }
  24.                 Console.WriteLine();
  25.             }
  26.         }
  27.         Console.ReadLine();
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement