Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <algorithm>
- #include <time.h>
- #include <vector>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "Russian");
- srand(time(NULL));
- int SIZE;
- cout << "Введите размерность матрицы: "; // ввод размерности
- cin >> SIZE;
- vector <vector <double>> arr(SIZE, vector <double>(SIZE)); // создает двумерный вектор размера SIZE
- for (int i = 0; i < SIZE; i++) // присванивание значений матрице
- {
- for (int j = 0; j < SIZE; j++)
- {
- arr[i][j] = rand() % 10;
- }
- }
- for (int i = 0; i < SIZE; i++) // вывод матрицы
- {
- for (int j = 0; j < SIZE; j++)
- {
- cout << arr[i][j] << "\t";
- }
- cout << endl;
- }
- for (int i = 0; i < SIZE - 1; i++) // транспонирование
- {
- for (int j = i + 1; j < SIZE; j++)
- {
- swap(arr[i][j], arr[j][i]);
- }
- cout << endl;
- }
- for (int i = 0; i < SIZE; i++) // вывод транспонированной матрицы
- {
- for (int j = 0; j < SIZE; j++)
- {
- cout << arr[i][j] << "\t";
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement