Language: C++



#include<bits/stdc++.h>
namespace std; int main(){ int n; cin >> n; int a,x,m; x=1; m=1; for(int i=0; i<n; ++i){ cin >> a; x=max(x,a); m=min(m,a); } 
cout << (x-m) << endl; }




Compiler output:
a.cc:4:14: error: expected '{' before ';' token
    4 | namespace std; int main(){ int n; cin >> n; int a,x,m; x=1; m=1; for(int i=0; i<n; ++i){ cin >> a; x=max(x,a); m=min(m,a); }
      |              ^
a.cc: In function 'int main()':
a.cc:4:35: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    4 | namespace std; int main(){ int n; cin >> n; int a,x,m; x=1; m=1; for(int i=0; i<n; ++i){ cin >> a; x=max(x,a); m=min(m,a); }
      |                                   ^~~
      |                                   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:3:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:4:102: error: 'max' was not declared in this scope; did you mean 'std::max'?
    4 | namespace std; int main(){ int n; cin >> n; int a,x,m; x=1; m=1; for(int i=0; i<n; ++i){ cin >> a; x=max(x,a); m=min(m,a); }
      |                                                                                                      ^~~
      |                                                                                                      std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:4:114: error: 'min' was not declared in this scope; did you mean 'std::min'?
    4 | namespace std; int main(){ int n; cin >> n; int a,x,m; x=1; m=1; for(int i=0; i<n; ++i){ cin >> a; x=max(x,a); m=min(m,a); }
      |                                                                                                                  ^~~
      |                                                                                                                  std::min
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:5:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    5 | cout << (x-m) << endl; }
      | ^~~~
      | std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:5:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
    5 | cout << (x-m) << endl; }
      |                  ^~~~
      |                  std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~