Polnochniy

Untitled

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