Qrist

NxN Matrix (Jagged Array)

Apr 14th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main(string[] args)
  5.     {
  6.         int n = int.Parse(Console.ReadLine());
  7.         Matrix(n);
  8.     }
  9.     public static void Matrix(int n)
  10.     {
  11.         int[][] array = new int[n][];
  12.         for (int i = 0; i < array.Length; i++)
  13.         {
  14.             array[i] = new int[n];
  15.             for (int k = 0; k < array.Length; k++)
  16.             {
  17.                 array[i][k] = n;
  18.                 Console.Write(array[i][k]+ " ");
  19.             }
  20.             Console.WriteLine();
  21.         }
  22.     }  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment