Language: C++

#include <iostream>
using namespace std;
int N,min,max;
int A[N+1];

int main(){
    cin >> N;
    for (int j = 0; j < N; ++i) cin >> A[j];
    min=A[0],max=A[0];
    for(int i=1;i<N;i++){
		if(min>A[i])
			min=A[i];
		if(max<A[i])
			max=A[i];
    }
    cout <<    max-min << endl;
}


Compiler output:
a.cc:4:8: error: size of array 'A' is not an integral constant-expression
    4 | int A[N+1];
      |       ~^~
a.cc: In function 'int main()':
a.cc:8:30: error: 'i' was not declared in this scope
    8 |     for (int j = 0; j < N; ++i) cin >> A[j];
      |                              ^
a.cc:9:5: error: reference to 'min' is ambiguous
    9 |     min=A[0],max=A[0];
      |     ^~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:3:7: note:                 'int min'
    3 | int N,min,max;
      |       ^~~
a.cc:9:14: error: reference to 'max' is ambiguous
    9 |     min=A[0],max=A[0];
      |              ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:3:11: note:                 'int max'
    3 | int N,min,max;
      |           ^~~
a.cc:11:20: error: reference to 'min' is ambiguous
   11 |                 if(min>A[i])
      |                    ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:3:7: note:                 'int min'
    3 | int N,min,max;
      |       ^~~
a.cc:12:25: error: reference to 'min' is ambiguous
   12 |                         min=A[i];
      |                         ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:3:7: note:                 'int min'
    3 | int N,min,max;
      |       ^~~
a.cc:13:20: error: reference to 'max' is ambiguous
   13 |                 if(max<A[i])
      |                    ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:3:11: note:                 'int max'
    3 | int N,min,max;
      |           ^~~
a.cc:14:25: error: reference to 'max' is ambiguous
   14 |                         max=A[i];
      |                         ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:3:11: note:                 'int max'
    3 | int N,min,max;
      |           ^~~
a.cc:16:16: error: reference to 'max' is ambiguous
   16 |     cout <<    max-min << endl;
      |                ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:3:11: note:                 'int max'
    3 | int N,min,max;
      |           ^~~
a.cc:16:20: error: reference to 'min' is ambiguous
   16 |     cout <<    max-min << endl;
      |                    ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:3:7: note:                 'int min'
    3 | int N,min,max;
      |       ^~~