1) если нужно найти произведение элементов с нечетными индексами:
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
signed main() {
int a[20];
srand(time(NULL));
for(int i = 0; i < 20; i++)
a[i] = rand()%46 - 19;
for(auto i: a)
cout << i << " ";
cout << "\n";
long long ans = 1;
for(int i = 0; i < 20; i++)
if(i % 2 == 1)
ans *= a[i];
cout << ans;
}
2) Если нужно найти произведение элементов с нечетными порядковыми номерами:
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
signed main() {
int a[20];
srand(time(NULL));
for(int i = 0; i < 20; i++)
a[i] = rand()%46 - 19;
for(auto i: a)
cout << i << " ";
cout << "\n";
long long ans = 1;
for(int i = 0; i < 20; i++)
if((i+1) % 2 == 1)
ans *= a[i];
cout << ans;
}
var i,j,k,n,sum:integer;
a:array[1..100] of integer;
flag:boolean;
begin
flag:=false;
writeln('Input N');
read(n);
writeln('Input elements');
for i:=1 to n do
read(a[i]);
for i:=1 to n do
for j:=1 to n do
for k:=1 to n do
if (i<>j) and (j<>k) and (i<>k) then
if a[i]+a[j]+a[k]=0 then
begin
writeln('Yes');
flag:=true;
halt;
end;
if flag=false then
writeln('No');
end.