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 ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Введите количество NxM элементов матрицы: ");
- int N = 0;
- int M = 0;
- string str = Console.ReadLine();
- string stl = Console.ReadLine();
- N = int.Parse(str);
- M = int.Parse(stl);
- Console.WriteLine("Исходная матрица: ");
- Console.WriteLine();
- int[,] sample = new int[N, M];
- Random rnd = new Random();
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < M; j++)
- {
- sample[i, j] = rnd.Next(1, 100); // заполнение матрицы случайными числами
- Console.Write(sample[i, j] + " \t ");
- }
- Console.WriteLine();
- }
- int[,] trans = new int[M, N];
- Console.WriteLine();
- Console.WriteLine("Транспонированная матрица: ");
- Console.WriteLine();
- for (int i = 0; i < M; i++)
- {
- for (int j = 0; j < N; j++)
- {
- trans[i, j] = sample[j, i];
- Console.Write(trans[i, j] + " \t ");
- }
- Console.WriteLine();
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement