Ответ:
// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <vector>
using std::cout;
int main()
{
std::vector<int> ints = { 1 , -2, -3, -4, 5, 6, -7, -8, -9, 10 };
cout << "vector before transformation: ";
for (auto integer : ints) {
cout << integer << " ";
}
cout << std::endl;
for (std::size_t i = 1; i < ints.size(); ) {
if (ints[i] < 0) {
ints.erase(ints.begin() + i);
i += 1;
continue;
}
i += 2;
}
cout << "vector after transformation: ";
for (auto integer : ints) {
cout << integer << " ";
}
cout << std::endl;
}
Объяснение:
По условию создаем вектор, удаляем элементы из вектора, если число ниже 0, движемся через один элемент по вектору ¯\_(ツ)_/¯
I,j,k:integer;
begin
for i:=1 to n do begin
for j:=1 to m do begin
a[i,j]:=random(21)-10;
write(a[i,j]:4);
end;
writeln;
end;
for i:=1 to n do
for j:=1 to m do
if a[i,j]mod 2<>0 then k:=k+1;
writeln('Количество нечетных ',k);
end.
Тестовое решение:
10 -1 -1 3 5 -3 -6 -1 2 8
-5 -5 -3 -1 3 -8 -1 -1 -6 -2
2 -3 5 0 -1 -4 0 3 7 -8
-6 5 6 3 -8 -6 -4 10 -3 0
-5 -4 2 -6 -10 -2 -1 3 5 -7
2 -10 2 10 -8 2 4 9 -6 -1
7 1 3 -1 3 0 0 4 -3 -1
7 -1 -8 4 -8 -5 6 1 0 -9
7 8 9 3 0 -6 -8 6 0 0
0 -3 6 8 4 4 4 -8 1 0
Количество нечетных 45
сколько кружочков в числе, то есть в 8 два кружка и число 8888 - 8 кружков, и число 8 в числе с вопросами, значит ответ - 2