Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //Write a program that reads from the console a positive integer number n (1 ≤ n ≤ 20) and prints a matrix
- //like in the examples below. Use two nested loops. Examples:
- // n matrix n matrix n matrix
- // 2 1 2 3 1 2 3 4 1 2 3 4
- // 2 3 2 3 4 2 3 4 5
- // 3 4 5 3 4 5 6
- // 4 5 6 7
- class MatrixOfNumbers
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- for (int row = 0; row < n; row++)
- {
- for (int col = 1; col <= n; col++)
- {
- Console.Write("{0,-3}",col+row);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment