Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Write a program that reads from the console a positive integer number N (N < 20) and outputs a matrix
- */
- using System;
- class MatrixOutput
- {
- static void Main()
- {
- byte numberN;
- string invalidInput = "Please enter a valid number 0 < N < 20!" + Environment.NewLine;
- Console.WriteLine("Enter a value for N: ");
- while (!(byte.TryParse(Console.ReadLine(), out numberN) && numberN > 0 && numberN < 20))
- {
- Console.WriteLine(invalidInput);
- Console.WriteLine("Enter a value for N: ");
- }
- Console.WriteLine();
- for (int j = 0; j < numberN; j++)
- {
- for (int k = 1; k <= numberN; k++)
- {
- Console.Write("{0,5} ", k + j);
- }
- Console.WriteLine();
- }
- Console.WriteLine();
- Main();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment