Venciity

[ Telerik C#] LOOPS - EX 12

Feb 13th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. // 12. Write a program that reads from the console a positive integer
  2. // number N (N < 20) and outputs a matrix.
  3. using System;
  4.  
  5. namespace ex12
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int n;
  12.             do
  13.             {
  14.                 Console.Write("Enter N: ");
  15.                 n = Int32.Parse(Console.ReadLine());
  16.             } while (!(n < 20 && n > 0));
  17.  
  18.             for (int i = 0; i < n; i++)
  19.             {
  20.                 for (int j = 1 + i; j <= n+i; j++)
  21.                 {
  22.                     Console.Write(j);
  23.                 }
  24.                 Console.WriteLine();
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment