
Зоил
7 год назад
Написать программу, которая заполняет одномерный массив случайными числами (-100 до 100) и выводит на экран произведение нечетных чисел
ОТВЕТЫ

Dake
Jul 14, 2019
#include lt;cstdlibgt;
#include lt;iostreamgt;
using namespace std;
int main() {
int i, prod = 1;
// [5;100]
const int SIZE = rand() 96 + 5;
int array[SIZE+1];
for(i = 0; i lt;= SIZE+1; i++) {
array[i] = (rand() 201) - 100;
if (array[i] lt; 0) {
prod *= array[i];
}
}
cout lt;lt; "произведение отрицательных чисел: " lt;lt; product;
return 0;
}
#include lt;iostreamgt;
using namespace std;
int main() {
int i, prod = 1;
// [5;100]
const int SIZE = rand() 96 + 5;
int array[SIZE+1];
for(i = 0; i lt;= SIZE+1; i++) {
array[i] = (rand() 201) - 100;
if (array[i] lt; 0) {
prod *= array[i];
}
}
cout lt;lt; "произведение отрицательных чисел: " lt;lt; product;
return 0;
}
150