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 stroka, stolbik;
- cout << "Введите кол-во строчек матрицы: "; // ввод размерности
- cin >> stroka;
- cout << "Введите кол-во столбиков матрицы: "; // ввод размерности
- cin >> stolbik;
- vector <vector <double>> arr(stroka, vector <double>(stolbik)); // создает двумерный вектор размера SIZE
- vector <vector <double>> trans(stolbik, vector <double>(stroka)); // создает двумерный вектор размера SIZE
- for (int i = 0; i < stroka; i++) // присванивание значений матрице
- {
- for (int j = 0; j < stolbik; j++)
- {
- arr[i][j] = rand() % 10;
- }
- }
- for (int i = 0; i < stroka; i++) // вывод матрицы
- {
- for (int j = 0; j < stolbik; j++)
- {
- cout << arr[i][j] << "\t";
- }
- cout << endl;
- }
- for (int i = 0; i < stroka ; i++) // транспонирование
- {
- for (int j = 0; j < stolbik; j++)
- {
- trans[j][i] = arr[i][j];
- }
- cout << endl;
- }
- /*for (int i = 0; i < stroka; i++)
- arr[i].clear();
- arr.clear();*/
- for (int i = 0; i < stolbik; i++) // вывод транспонированной матрицы
- {
- for (int j = 0; j < stroka; j++)
- {
- cout << trans[i][j] << "\t";
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement