Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "Rus");
- int N;
- cout << "Введите число элементов " << endl;
- cin >> N;
- int* a = new int[N];
- cout << "Введите элементы массива . Ввывести соседние элементы , одного знака, в противном случаи '0' " << endl;
- for (int i = 0; i < N; i++)
- {
- cin >> a[i];
- }
- bool flag = false;
- for (int i = 0; (i < N - 1) && (flag == false); i++)
- {
- if (a[i] * a[i + 1] > 0)
- {
- if (a[i] < a[i + 1])
- {
- cout << a[i] << " " << a[i + 1];
- }
- else
- {
- cout << a[i + 1] << " " << a[i];
- }
- flag = true;
- }
- }
- if (flag == false)
- {
- cout << "0";
- }
- delete[] a;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement