desislava_topuzakova

1. Вход и изход на матрица

Mar 20th, 2022
1,135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _1._MatrixInputOutput
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int rows = int.Parse(Console.ReadLine());
  10.             int cols = int.Parse(Console.ReadLine());
  11.  
  12.             int[,] numbers = new int[rows, cols];
  13.  
  14.             //input matrix
  15.             for (int row = 0; row <= rows - 1; row++)
  16.             {
  17.                 for (int col = 0; col <= cols - 1; col++)
  18.                 {
  19.                     numbers[row, col] = int.Parse(Console.ReadLine());
  20.                 }
  21.             }
  22.  
  23.             //output matrix
  24.             for (int row = 0; row <= rows - 1; row++)
  25.             {
  26.                 for (int col = 0; col <= cols - 1; col++)
  27.                 {
  28.                     Console.Write(numbers[row, col] + " ");
  29.                 }
  30.                 Console.WriteLine();
  31.             }
  32.         }
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment