uses Drawman;
begin
field(20,17);
PenUp;
ToPoint(0,0);
PenDown;
ToPoint(20,0);
ToPoint(20,10);
ToPoint(19,10);
ToPoint(19,1);
ToPoint(1,1);
ToPoint(1,16);
ToPoint(19,16);
ToPoint(19,13);
ToPoint(20,13);
ToPoint(1,3);
ToPoint(7,3); ToPoint(7,1);
ToPoint(9,1);
ToPoint(9,4);
ToPoint(17,4);
ToPoint(17,1);
ToPoint(17,9);
ToPoint(19,9);
PenUp; ToPoint(19,13); PenDown;
ToPoint(14,13);
ToPoint(14,16);
ToPoint(14,14);
ToPoint(9,14);
ToPoint(9,16);
ToPoint(9,13);
ToPoint(4,13);
ToPoint(4,16);
end.
Решение данной задачи будет выглядеть вот так:
int main()
{
setlocale(LC_ALL, "Rus");
int A[5][5] = {
{10, 4, 5, 34, 12},
{32, 6, 23, 15, 22},
{10, 4, 7, 32, 6},
{3, 22, 21, 15, 8},
{9, 4, 31, 19, 5}
};
int n = 5;
int sum = 0;
int max = -1;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
cout << A[i][j] << "\t";
}
cout << endl;
cout << "Сумма элементов столбцов с чётными номерами:" << endl;
sum = 0;
if (j % 2 == 0) //Проверка на парность "j % 2 == 0" - остаток от деление на 2 равен 0
sum += A[i][j];
cout << i+1 << ": " << sum << endl;
cout << "Максимальный элемент для каждого столбца:" << endl;
max = -1;
if (max <= A[i][j])
max = A[i][j];
cout << j + 1 << ": " << max << endl;
return 0;
uses Drawman;
begin
field(20,17);
PenUp;
ToPoint(0,0);
PenDown;
ToPoint(20,0);
ToPoint(20,10);
ToPoint(19,10);
ToPoint(19,1);
ToPoint(1,1);
ToPoint(1,16);
ToPoint(19,16);
ToPoint(19,13);
ToPoint(20,13);
PenUp;
ToPoint(1,3);
PenDown;
ToPoint(7,3); ToPoint(7,1);
ToPoint(9,1);
ToPoint(9,4);
ToPoint(17,4);
ToPoint(17,1);
ToPoint(17,9);
ToPoint(19,9);
PenUp; ToPoint(19,13); PenDown;
ToPoint(14,13);
ToPoint(14,16);
ToPoint(14,14);
ToPoint(9,14);
ToPoint(9,16);
ToPoint(9,13);
ToPoint(4,13);
ToPoint(4,16);
end.
Решение данной задачи будет выглядеть вот так:
int main()
{
setlocale(LC_ALL, "Rus");
int A[5][5] = {
{10, 4, 5, 34, 12},
{32, 6, 23, 15, 22},
{10, 4, 7, 32, 6},
{3, 22, 21, 15, 8},
{9, 4, 31, 19, 5}
};
int n = 5;
int sum = 0;
int max = -1;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
cout << A[i][j] << "\t";
}
cout << endl;
}
cout << endl;
cout << "Сумма элементов столбцов с чётными номерами:" << endl;
for (int i = 0; i < n; i++)
{
sum = 0;
for (int j = 0; j < n; j++)
{
if (j % 2 == 0) //Проверка на парность "j % 2 == 0" - остаток от деление на 2 равен 0
{
sum += A[i][j];
}
}
cout << i+1 << ": " << sum << endl;
}
cout << endl;
cout << "Максимальный элемент для каждого столбца:" << endl;
for (int j = 0; j < n; j++)
{
max = -1;
for (int i = 0; i < n; i++)
{
if (max <= A[i][j])
{
max = A[i][j];
}
}
cout << j + 1 << ": " << max << endl;
}
cout << endl;
return 0;
}