#include <iostream>
#include <vector>

std::vector<std::vector<int>>
transpose (const std::vector<std::vector<int>>& input)
{
    std::vector<std::vector<int>> res(input[0].size(), std::vector<int>(input.size()));
    for (std::size_t i = 0; i != input.size(); ++i) {
        for (std::size_t j = 0; j != input[i].size(); ++j) {
            res[j][i] = input[i][j];
        }
    }
    return res;
}

void print(const std::vector<std::vector<int>>& m)
{
    for (std::size_t i = 0; i != m.size(); ++i) {
        for (std::size_t j = 0; j != m[i].size(); ++j) {
            std::cout << m[i][j] << " ";
        }
        std::cout << std::endl;
    }
}

int main ()
{
    int width;
    int length;

    std::cout << "enter the width followed by the length of the matrix: ";
    std::cin >> width >> length;

    std::vector<std::vector<int>> input(width, std::vector<int> (length));
    std::cout << "enter elements \n";
    for (int j = 0; j < length; j++)
        for (int i = 0; i < width; i++) {
            std::cin >> input[i][j];
        }

    std::cout << "your matrix is: \n";
    print(input);
    std::vector<std::vector<int>> output = transpose(input);

    std::cout << "the transpose is: \n";
    print(output);
    return 0;
}
