Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //4.3
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL,"");
- srand(time(0));
- int n;
- float sum{0};
- double mult{1};
- cout << "Количество элементов массива n : ";
- cin >> n;
- float arr[n];ы
- cout << "\nМассив arr : ";
- for (int i = 0; i < n; i++)
- {
- arr[i] = (rand() % 100) / 2.5;
- cout << arr[i] << " ";
- }
- for (int i = 0; i < n; i++)
- {
- if (i%2==0) mult *= arr[i];
- if (i%2!=0) sum += arr[i];
- }
- cout << "\n\nПроизведение четных элементов : " << mult;
- cout << "\n\nСумма нечетных элементов : " << sum << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement