Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(0, "");
- const int n = 117;
- int p1 = 0, p2 = 0, y = 0, max = 0, q1 = 0, q2 = 0;
- int arr[n] = {};
- cout << "Введите числа подряд: ";
- cin >> y;
- cin >> q1;
- for (int i = 0; i < n; i++)
- arr[i] = 0;
- for (int i = 2; i <= y; i++)
- {
- cin >> q2;
- if (q1 > arr[q1 % n])
- arr[q1 % n] = q1;
- for (int j = 0; j < n; j++)
- {
- if ((arr[j] + q2 > max) && ((arr[j] + q2) % n == 0) && (arr[j] > q2))
- {
- max = arr[j] + q2;
- p1 = arr[j];
- p2 = q2;
- }
- }
- q1 = q2;
- }
- if ((p1 + p2) > 0)
- cout << p1 << ' ' << p2;
- else
- cout << "NO";
- cout << endl << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement