Polnochniy

Untitled

Nov 23rd, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3.  
  4. using namespace std;
  5. int main()
  6. {
  7. setlocale(LC_ALL, "Rus");
  8. srand(time(0));
  9. int N;
  10. int P = 1;
  11. cout << "Количество элементов массива: .";
  12. cin >> N;
  13.  
  14. int* a = new int[N];
  15.  
  16. for (int i = 0; i < N; i++) {
  17. a[i] = rand() % 20;
  18. cout << a[i] << " ";
  19. }
  20.  
  21. cout << endl;
  22. for (int i = 0; i < N; i += 2)
  23. P *= a[i];
  24.  
  25. cout << "Произведение элементов стоящих на четных местах : " << P;
  26.  
  27. cout << endl;
  28. delete[] a;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment