ответ:
var
a: array [1..3] of integer;
i, imin: integer;
begin
for i : = low (a) to high (a) do begin
write (i, ' число: ');
readln (a [i]);
end;
imin : = 0;
for i : = low (a) to high (a) do begin
if a [i] mod 2 = 0 then
if imin = 0 then
imin : = i
else if a [i] < a [imin] then
imin : = i;
end;
if imin < > 0 then
writeln ('наименьшее четное = ', a [imin])
else
writeln ('четных чисел нет.');
readln;
end.
Поделитесь своими знаниями, ответьте на вопрос:
ответ:
#include
#include
using namespace std;
int main()
{
int a[5][5] =
{
{4,-5,8,-3,1},
{-3,8,-1,1,-8},
{9,6,6,-3,-7},
{-7,-3,3,6,-7},
{7,-3,-6,5,0},
};
int b[5][5];
int i, j, cp, cm, sp, sm;
setlocale(lc_all, "russian");
cout < < "массив a";
for (i = 0; i < 5; i++) {
cout < < endl;
for (j = 0; j < 5; j++) {
cout < < setw (4) < < a[i][j];
}
}
cp = cm = sp = sm = 0;
for (i = 0; i < 5; i++) {
for (j = 0; j < 5; j++) {
if (a[i][j] > = -5)
b[i][j] = a[i][j];
else
b[i][j] = - a[i][j];
if (a[i][j] > 0) {
cp++;
sp += a[i][j];
}
if (a[i][j] < 0) {
cm++;
sm += a[i][j];
}
}
}
cout < < endl < < endl;
cout < < "среднее значение положительных элементов = " < < (float) sp / cp < < endl;
cout < < "среднее значение отрицательных элементов = " < < (float) sm / cm < < endl < < endl;
cout < < "массив b";
for (i = 0; i < 5; i++) {
cout < < endl;
for (j = 0; j < 5; j++) {
cout < < setw(4) < < b[i][j];
}
}
return 0;
}