Polnochniy

Untitled

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