1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include <iostream>
void main()
{
double u[4][4] = { {1,6,3,11},{4,5,6,2},{7,-8,9,6},{12,2,-5,-12} };
double b[4] = { 1,2,3,4 };
for (int k = 0; k < 4; k++)
{
for (int i = k + 1; i < 4; i++)
{
if (u[k][k] < u[i][k])
{
for (int col = k; col < 4; col++)
{
std::swap(u[k][col], u[i][col]);
}
std::swap(b[k], b[i]);
}
}
}
for (int rowu = 0; rowu < 4; ++rowu)
{
for (int colu = 0; colu < 4; ++colu)
{
std::cout << u[rowu][colu] << " ";
}
std::cout << '\n';
}
std::cout << '\n';
for (int i = 0; i < 4; i++)
{
std::cout << b[i] << " \n";
}
}
|