Advertisement
Atanasov_88

Untitled

Sep 24th, 2015
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. class Program
  8. {
  9.     static void Main()
  10.     {
  11.         Console.WriteLine("Enter numbers of rows: ");
  12.         int rows = int.Parse(Console.ReadLine());
  13.         Console.WriteLine("Enter numbers of cols: ");
  14.         int cows = int.Parse(Console.ReadLine());
  15.  
  16.         int[,] matrix = new int[rows, cows];
  17.  
  18.         for (int row = 0; row < rows; row++)
  19.         {
  20.             for (int cow = 0; cow < cows; cow++)
  21.             {
  22.                 Console.Write("Element {0}{1} is: ", row, cow);
  23.                 int element = int.Parse(Console.ReadLine());
  24.                 matrix[row, cow] = element;
  25.             }
  26.         }
  27.  
  28.         Console.WriteLine("The filled matrix is: ");
  29.  
  30.         for (int row = 0; row < rows; row++)
  31.         {
  32.             for (int cow = 0; cow < cows; cow++)
  33.             {
  34.                 Console.Write("{0} ", matrix[row, cow]);
  35.  
  36.             }
  37.             Console.WriteLine();
  38.         }
  39.  
  40.  
  41.     }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement