Advertisement
Polnochniy

Untitled

Nov 21st, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. int main()
  5. {
  6. setlocale(LC_ALL, "Rus");
  7. int N;
  8. cout << "Введите число элементов " << endl;
  9. cin >> N;
  10. int* a = new int[N];
  11. cout << "Введите элементы массива . Ввывести соседние элементы , одного знака, в противном случаи '0' " << endl;
  12. for (int i = 0; i < N; i++)
  13. {
  14. cin >> a[i];
  15. }
  16. bool flag = false;
  17. for (int i = 0; (i < N - 1) && (flag == false); i++)
  18. {
  19. if (a[i] * a[i + 1] > 0)
  20. {
  21. if (a[i] < a[i + 1])
  22. {
  23. cout << a[i] << " " << a[i + 1];
  24. }
  25. else
  26. {
  27. cout << a[i + 1] << " " << a[i];
  28. }
  29. flag = true;
  30. }
  31.  
  32. }
  33. if (flag == false)
  34. {
  35. cout << "0";
  36. }
  37. delete[] a;
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement