Advertisement
elena1234

Matrix-create and iterate

Dec 16th, 2020 (edited)
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Matrix
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int[,] matrix =
  10.              {
  11.                 {1,2},
  12.                 {3,4 },
  13.                 {7,6},
  14.                 {1,2},
  15.             };
  16.  
  17.             for (int row = 0; row < matrix.GetLength(0); row++)
  18.             {
  19.                 for (int col = 0; col < matrix.GetLength(1); col++)
  20.                 {
  21.                     Console.Write(matrix[row, col] + " ");
  22.                 }
  23.  
  24.                 Console.WriteLine();
  25.             }
  26.         }
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement