Advertisement
kish-dev

c++

Oct 12th, 2020 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int N, a1, a2, outNumber, a3;
  7. cin >> N;
  8. int k = 1;
  9. if (N >= 3)
  10. {
  11. cin >> a1;
  12. cin >> a2;
  13. cin >> a3;
  14. for (int i = 0; i < N - 3; ++i)
  15. {
  16. if (k != 0)
  17. {
  18. if ((a2 - a1 == a3 - a2) && (a2 - a1 > 0))
  19. {
  20. outNumber = a3;
  21. k = 0;
  22. }
  23. else
  24. {
  25. a1 = a2;
  26. a2 = a3;
  27. cin >> a3;
  28. }
  29. }
  30. else
  31. {
  32. cout << a1 << " " << a2 << " " << a3;
  33. return 0;
  34. }
  35. }
  36. cout << -1;
  37. }
  38. else
  39. {
  40. cout << -1;
  41. }
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement