#include <iostream>
#include <conio.h> // библиотека, необходимая для работы оператора getch();
int main()
{
const int col = 3;
const int rev = 2;
int array[col][rev] = { { 0, 2 },
{ 1, 2 },
{ 3, 4 } };
std::cout << "Initial array:" << std::endl;
for (int i = 0; i < col; i++)
{
for (int j = 0; j < rev; j++)
{
std::cout << array[i][j] << "\t";
}
std::cout << std::endl;
}
int arrayT[rev][col];
for (int i = 0; i < col; i++)
{
for (int j = 0; j < rev; j++)
{
arrayT[j][i] = array[i][j];
}
}
std::cout << std::endl;
std::cout << "Transposed array:" << std::endl;
for (int i = 0; i < rev; i++)
{
for (int j = 0; j < col; j++)
{
std::cout << arrayT[i][j] << "\t";
}
std::cout << std::endl;
}
getch();
return 0;
}
#include <iostream>
#include <conio.h> // библиотека, необходимая для работы оператора getch();
int main()
{
const int col = 3;
const int rev = 2;
int array[col][rev] = { { 0, 2 },
{ 1, 2 },
{ 3, 4 } };
std::cout << "Initial array:" << std::endl;
for (int i = 0; i < col; i++)
{
for (int j = 0; j < rev; j++)
{
std::cout << array[i][j] << "\t";
}
std::cout << std::endl;
}
int arrayT[rev][col];
for (int i = 0; i < col; i++)
{
for (int j = 0; j < rev; j++)
{
arrayT[j][i] = array[i][j];
}
}
std::cout << std::endl;
std::cout << "Transposed array:" << std::endl;
for (int i = 0; i < rev; i++)
{
for (int j = 0; j < col; j++)
{
std::cout << arrayT[i][j] << "\t";
}
std::cout << std::endl;
}
getch();
return 0;
}
Initial array:
0 2
1 2
3 4
Transposed array:
0 1 3
2 2 4
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.