Advertisement
dsavov_02

introprogramming

Feb 24th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. using System;
  2.  
  3. public class Program
  4. {
  5. public static void Main()
  6. {
  7. Console.WriteLine("Enter rows: ");
  8. int rows= int.Parse(Console.ReadLine());
  9.  
  10. Console.WriteLine("Enter colums: ");
  11. int cols= int.Parse(Console.ReadLine());
  12.  
  13. int[,] matrix= new int[rows,cols];
  14.  
  15. Console.WriteLine("Enter the cells of the matrix:");
  16.  
  17. for(int row=0; row < rows; row++)
  18. {
  19. for(int col = 0; col< cols; col++)
  20. {
  21. Console.Write("matrix[{0}, {1}] = ", row,col);
  22. matrix[row,col] = int.Parse(Console.ReadLine());
  23. }
  24. }
  25.  
  26. for(int row = 0 ; row< matrix.GetLength(1); row++)
  27. {
  28. for(int col = 0 ; col< matrix.GetLength(1); col++)
  29. {
  30. Console.Write(" " + matrix[row,col]);
  31. }
  32. Console.WriteLine();
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement