80552024-01-12 11:36:25bzsofiaLegmesszebbi rossz sorrendű (35 pont)cpp17Compilation error
// Sorrend.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>

using namespace std;

int i, n, j, maxt=INT_MIN, maxi, maxj;

int main()
{
    cin >> n;
    vector <int> x(n + 1);

    for (i = 1; i <= n; ++i)
    {
        cin >> x[i];
    }

    i = 1;
    j = n;
    while (i<j && j - i + 1>maxt)
    {
        if (x[i] > x[j])
        {
            maxt = j - i + 1;
            maxi = i;
            maxj = j;
            j = n;
            ++i;
        }
        else
        {
            if (i + 1 == j)
            {
                ++i;
                j = n;
            }
            else
            {
                --j;
            }
        }
    }

    if (maxi == 0 && maxj == 0) cout << "-1";
    else cout << maxi << " " << maxj;

    return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Compilation error
exit status 1
main.cpp:9:19: error: 'INT_MIN' was not declared in this scope
    9 | int i, n, j, maxt=INT_MIN, maxi, maxj;
      |                   ^~~~~~~
main.cpp:6:1: note: 'INT_MIN' is defined in header '<climits>'; did you forget to '#include <climits>'?
    5 | #include <vector>
  +++ |+#include <climits>
    6 | 
main.cpp: In function 'int main()':
main.cpp:28:13: error: 'maxi' was not declared in this scope; did you mean 'maxt'?
   28 |             maxi = i;
      |             ^~~~
      |             maxt
main.cpp:29:13: error: 'maxj' was not declared in this scope; did you mean 'maxt'?
   29 |             maxj = j;
      |             ^~~~
      |             maxt
main.cpp:47:9: error: 'maxi' was not declared in this scope; did you mean 'maxt'?
   47 |     if (maxi == 0 && maxj == 0) cout << "-1";
      |         ^~~~
      |         maxt
main.cpp:47:22: error: 'maxj' was not declared in this scope; did you mean 'maxt'?
   47 |     if (maxi == 0 && maxj == 0) cout << "-1";
      |                      ^~~~
  ...