Language: C++

import java.io.*;
import java.util.StringTokenizer;
  
class Main{
  
static final PrintWriter out=new PrintWriter(System.out);
static int ans=0;
  
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
SelectionSort(a);
getValue(a);
out.println(ans);
out.flush();
}
}
  
private static void swap(int[] a,int s,int t){
int tmp=a[s]; a[s]=a[t]; a[t]=tmp; ans++;
}
  
private static void SelectionSort(int[] a){
for(int i=0;i<a.length;i++){
int min=i;
for(int j=i;j<a.length;j++){
if(a[j]<a[min]){
min=j;
if(i!=min) swap(a,i,min);
}
}
}
}
  
private static void getValue(int[] a){
for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
out.println(a[a.length-1]);
}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.StringTokenizer;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:8: error: 'final' does not name a type
    6 | static final PrintWriter out=new PrintWriter(System.out);
      |        ^~~~~
a.cc:7:12: error: ISO C++ forbids in-class initialization of non-const static member 'Main::ans'
    7 | static int ans=0;
      |            ^~~
a.cc:9:7: error: expected ':' before 'static'
    9 | public static void main(String[] args) throws IOException{
      |       ^~~~~~~
      |       :
a.cc:9:25: error: 'String' has not been declared
    9 | public static void main(String[] args) throws IOException{
      |                         ^~~~~~
a.cc:9:34: error: expected ',' or '...' before 'args'
    9 | public static void main(String[] args) throws IOException{
      |                                  ^~~~
a.cc:9:38: error: expected ';' at end of member declaration
    9 | public static void main(String[] args) throws IOException{
      |                                      ^
      |                                       ;
a.cc:9:40: error: 'throws' does not name a type
    9 | public static void main(String[] args) throws IOException{
      |                                        ^~~~~~
a.cc:24:8: error: expected ':' before 'static'
   24 | private static void swap(int[] a,int s,int t){
      |        ^~~~~~~
      |        :
a.cc:24:32: error: expected ',' or '...' before 'a'
   24 | private static void swap(int[] a,int s,int t){
      |                                ^
a.cc:28:8: error: expected ':' before 'static'
   28 | private static void SelectionSort(int[] a){
      |        ^~~~~~~
      |        :
a.cc:28:41: error: expected ',' or '...' before 'a'
   28 | private static void SelectionSort(int[] a){
      |                                         ^
a.cc:40:8: error: expected ':' before 'static'
   40 | private static void getValue(int[] a){
      |        ^~~~~~~
      |        :
a.cc:40:36: error: expected ',' or '...' before 'a'
   40 | private static void getValue(int[] a){
      |                                    ^
a.cc:44:2: error: expected ';' after class definition
   44 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::swap(int*)':
a.cc:25:9: error: 'a' was not declared in this scope
   25 | int tmp=a[s]; a[s]=a[t]; a[t]=tmp; ans++;
      |         ^
a.cc:25:11: error: 's' was not declared in this scope
   25 | int tmp=a[s]; a[s]=a[t]; a[t]=tmp; ans++;
      |           ^
a.cc:25:22: error: 't' was not declared in this scope
   25 | int tmp=a[s]; a[s]=a[t]; a[t]=tmp; ans++;
      |                      ^
a.cc: In static member function 'static void Main::SelectionSort(int*)':
a.cc:29:15: error: 'a' was not declared in this scope
   29 | for(int i=0;i<a.length;i++){
      |               ^
a.cc: In static member function 'static void Main::getValue(int*)':
a.cc:41:15: error: 'a' was not declared in this scope
   41 | for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
      |               ^
a.cc:41:31: error: 'out' was not declared in this scope
   41 | for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
      |                               ^~~
a.cc:42:1: error: 'out' was not declared in this scope
   42 | out.println(a[a.length-1]);
      | ^~~
a.cc:42:13: error: 'a' was not declared in this scope
   42 | out.println(a[a.length-1]);
      |             ^