#include <iostream> #include <iomanip> #include <random> using namespace std; int rnd(int a, int b); void fill(int* arr, const size_t size, int left, int right); long long mult(int* arr, const size_t size, int cp = -1); void show(int* arr, const size_t size, streamsize w = 4); void test(int* arr, const size_t size, int left, int right); int main() { const size_t size = 10; int arr[size]; int left = -5; int right = 15; for (size_t i = 10; i; --i) test(arr, size, left, right); cin.sync(); cin.get(); } void test(int* arr, const size_t size, int left, int right) { fill(arr, size, left, right); show(arr, size); long long m = mult(arr, size); if (m > -1) cout << " Mult = " << m << endl; else cout << " No such! "; } void show(int* arr, const size_t size, streamsize w) { for (size_t i = 0; i != size; ++i) cout << setw(w) << arr; cout << endl; } long long mult(int* arr, const size_t size, int cp) { long long m = 1; size_t i; for (i = 0; i != size; ++i) { if (arr <= cp) break; m *= arr; } if (0 == i) m = -1; return m; } void fill(int* arr, const size_t size, int left, int right) { for (size_t i = 0; i != size; ++i) arr = rnd(left, right); } int rnd(int a, int b) { if (a > b) swap(a, b); uniform_int_distribution<int> uid(a, b); random_device rd; return uid(rd); }