Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  int X;
  int a;
  int i
  X=1;
  cin >> N;
  vector<int> vec(101);
  
  for (int i = 1; i < N+1; i++) {
  cin >> vec.at(i);
  }
  
   if (vec.at(i) == *max_element(vec.begin(), vec.end())) {
      cout << i << endl;
     i=a;
     X++;
     }
  
   for (int k = 1; k < N+1; k++) {  
     
   if (vec.at(k) == *max_element(vec.begin(), vec.at(a))) {
      cout << a << endl;
     k=a;
     X++;
     }
     
  if (vec.at(k) == vec.at(k)) {
break;
     }
     
  }

   cout << X << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: expected initializer before 'X'
    9 |   X=1;
      |   ^
a.cc:17:15: error: 'i' was not declared in this scope
   17 |    if (vec.at(i) == *max_element(vec.begin(), vec.end())) {
      |               ^
a.cc:25:33: error: no matching function for call to 'max_element(std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   25 |    if (vec.at(k) == *max_element(vec.begin(), vec.at(a))) {
      |                      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5641:5: note: candidate: 'template<class _FIter> constexpr _FIter std::max_element(_FIter, _FIter)'
 5641 |     max_element(_ForwardIterator __first, _ForwardIterator __last)
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5641:5: note:   template argument deduction/substitution failed:
a.cc:25:33: note:   deduced conflicting types for parameter '_FIter' ('__gnu_cxx::__normal_iterator<int*, std::vector<int> >' and 'int')
   25 |    if (vec.at(k) == *max_element(vec.begin(), vec.at(a))) {
      |                      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5666:5: note: candidate: 'template<class _FIter, class _Compare> constexpr _FIter std::max_element(_FIter, _FIter, _Compare)'
 5666 |     max_element(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5666:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:524:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::max_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Compare)'
  524 | max_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Compare __comp);
      | ^~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:524:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:528:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::max_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator)'
  528 | max_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:528:1: note:   candidate expects 3 arguments, 2 provided