Language: C++

#include<iostream>
#include<algorithm>
//using namespace std;
void selectionSort()
{
    int A[100];
    int N;
    cin >> N;
 
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int m = i;
        for (int j = i + 1; j < N; j++)
        {
            if (A[m] > A[j])
            {
                m = j;
            }
        }
 
        if (m != i)
        {
            int temp = A[i];
            A[i] = A[m];
            A[m] = temp;
            ans++;
        }
    }
 
    for (int i = 0; i < N; i++)
    {
        if (i != N - 1)
        {
            cout << A[i] << " " << flush;
            continue;
        }
        else
        {
            cout << A[i] << endl;
        }
    }
 
    cout << ans << endl;
}
 
int main()
{
    selectionSort();
    return 0;
}


Compiler output:
a.cc: In function 'void selectionSort()':
a.cc:8:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |     cin >> N;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:39:13: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   39 |             cout << A[i] << " " << flush;
      |             ^~~~
      |             std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:39:36: error: 'flush' was not declared in this scope; did you mean 'std::flush'?
   39 |             cout << A[i] << " " << flush;
      |                                    ^~~~~
      |                                    std::flush
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:766:5: note: 'std::flush' declared here
  766 |     flush(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~~
a.cc:44:13: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   44 |             cout << A[i] << 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:44:29: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   44 |             cout << A[i] << endl;
      |                             ^~~~
      |                             std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:48:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   48 |     cout << ans << 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:48:20: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   48 |     cout << ans << endl;
      |                    ^~~~
      |                    std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~