Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MatrixSoftuni
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random rand = new Random();
- int n = int.Parse(Console.ReadLine());
- int m = int.Parse(Console.ReadLine());
- int[,] matrix = new int[n, m];
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- matrix[i, j] = rand.Next(10);
- }
- }
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- Console.Write($"{matrix[i, j]} ");
- }
- Console.WriteLine();
- }
- for (int i = 0; i < m; i++)
- {
- // matrix[0, i] <=> matrix[n - 1, i]
- int temp = matrix[0, i];
- matrix[0, i] = matrix[n - 1, i];
- matrix[n - 1, i] = temp;
- }
- Console.WriteLine();
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- Console.Write($"{matrix[i, j]} ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement