Polnochniy

Untitled

Jan 7th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 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 << " Найти произведение положительных элементов и количество отрицательных " << endl;
  11. cout << " Введите количество элементов массива: ";
  12. cin >> N;
  13. int* a = new int[N];
  14. cout << "Введите элементы массива: " << endl;
  15. for (int i = 0; i < N; i++)
  16. {
  17. cin >> a[i];
  18. }
  19. for (int i = 0; i < N; i++)
  20. {
  21. if (a[i] >=0)
  22. P *= a[i];
  23. if (a[i] < 0)
  24. sum++;
  25. }
  26. cout << " Произведение положительных элементов массива равна : " << P << endl;
  27. cout << "Количество отрицательных элементов массива равна: " << sum << endl;
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment