Language: C++

#include<iostream>
#include<algorithm>
 
int selectionSort(int A[], int N) {
  int sw = 0;
  for ( int i = 0; i < N; i++){
    minj = i;
    for ( int j = i; j < N - 1; j++){
      if (A[j] < A[minj]) {
        minj = j;
      }
    }
    swap(A[minj], A[i]);
    sw++;
  }
  return sw;
}
 
int main() {
  int sw, N, A[100];
  cin >> N;
   
  for ( int i = 0; i < N; i++) cin >> A[i];
   
  sw = selectionSort(A, N);
 
  for ( int i = 0; i < N; i++) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
 
  return 0;
}


Compiler output:
a.cc: In function 'int selectionSort(int*, int)':
a.cc:7:5: error: 'minj' was not declared in this scope
    7 |     minj = i;
      |     ^~~~
a.cc:13:5: error: 'swap' was not declared in this scope
   13 |     swap(A[minj], A[i]);
      |     ^~~~
a.cc:13:5: note: suggested alternatives:
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68,
                 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/tuple:2823:5: note:   'std::swap'
 2823 |     swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
      |     ^~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41:
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
/usr/include/c++/14/bits/exception_ptr.h:229:5: note:   'std::__exception_ptr::swap'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
a.cc: In function 'int main()':
a.cc:21:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   21 |   cin >> N;
      |   ^~~
      |   std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:28:12: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   28 |     if (i) cout << " ";
      |            ^~~~
      |            std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:29:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   29 |     cout << A[i];
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:31:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   31 |   cout << 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:31:11: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   31 |   cout << endl;
      |           ^~~~
      |           std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~