#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
setlocale(LC_ALL, "russian");
int a[100][100];
int n; int r;
cin >> n;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
a[i][j] = rand() % 10;
}
int sum[50];
sum[i] = 0;
if (i%2==0)
for (int k = j; k < n; k++)
int min = k;
for (int u = k + 1; u < n; u++)
if (a[i][u] < a[i][min])
min = u;
int buf = a[i][k];
a[i][k] = a[i][min];
a[i][min] = buf;
if (i % 2 == 0)
sum[i] += a[i][j];
if (i%2==1)
a[i][j] = sum[i-1];
cout << endl;
cout<<a[i][j]<< " ";
return 0;
Объяснение:
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
setlocale(LC_ALL, "russian");
int a[100][100];
int n; int r;
cin >> n;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
a[i][j] = rand() % 10;
}
int sum[50];
for (int i = 0; i < n; i++)
{
sum[i] = 0;
for (int j = 0; j < n; j++)
{
if (i%2==0)
{
for (int k = j; k < n; k++)
{
int min = k;
for (int u = k + 1; u < n; u++)
if (a[i][u] < a[i][min])
{
min = u;
int buf = a[i][k];
a[i][k] = a[i][min];
a[i][min] = buf;
}
}
}
}
}
for (int i = 0; i < n; i++)
{
sum[i] = 0;
for (int j = 0; j < n; j++)
{
if (i % 2 == 0)
{
sum[i] += a[i][j];
}
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
if (i%2==1)
{
a[i][j] = sum[i-1];
}
}
for (int i = 0; i < n; i++)
{
cout << endl;
for (int j = 0; j < n; j++)
cout<<a[i][j]<< " ";
}
return 0;
}
Объяснение: