Language: Java

#include<stdio.h>
#include<stdlib.h>

int main(){
  int i;
  int j;
  int change = 0;
  int num = 0;
  int count = 0;
  int min = 0;
  int *data;

scanf("%d",&num);
data = (int *)malloc(sizeof(int)*num);

for(j = 0;j < num;j++){
  scanf("%d",&data[j]);
}

for(i = 0;i < num - 1;i++){
  min = i;
  for(j = i;j < num;j++){
    if(data[j] < data[min]){
      min = j;
    }

  }
  if(i != min){
    change = data[i];
    data[i] = data[min];
    data[min] = change;
    count++;
  }
}

for(i = 0;i < num-1;i++){
  printf("%d ",data[i]);
}
printf("%d",data[num - 1]);
printf("\n");
printf("%d",count);
printf("\n");
return 0;
}



Compiler output:
Main.java:1: error: illegal character: '#'
#include<stdio.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include<stdio.h>
        ^
Main.java:2: error: illegal character: '#'
#include<stdlib.h>
^
Main.java:6: error: unnamed classes are a preview feature and are disabled by default.
  int j;
  ^
  (use --enable-preview to enable unnamed classes)
Main.java:11: error: class, interface, enum, or record expected
  int *data;
  ^
Main.java:13: error: class, interface, enum, or record expected
scanf("%d",&num);
^
Main.java:14: error: class, interface, enum, or record expected
data = (int *)malloc(sizeof(int)*num);
^
Main.java:16: error: class, interface, enum, or record expected
for(j = 0;j < num;j++){
^
Main.java:16: error: class, interface, enum, or record expected
for(j = 0;j < num;j++){
          ^
Main.java:16: error: class, interface, enum, or record expected
for(j = 0;j < num;j++){
                  ^
Main.java:18: error: class, interface, enum, or record expected
}
^
Main.java:20: error: class, interface, enum, or record expected
for(i = 0;i < num - 1;i++){
          ^
Main.java:20: error: class, interface, enum, or record expected
for(i = 0;i < num - 1;i++){
                      ^
Main.java:22: error: class, interface, enum, or record expected
  for(j = i;j < num;j++){
  ^
Main.java:22: error: class, interface, enum, or record expected
  for(j = i;j < num;j++){
            ^
Main.java:22: error: class, interface, enum, or record expected
  for(j = i;j < num;j++){
                    ^
Main.java:25: error: class, interface, enum, or record expected
    }
    ^
Main.java:30: error: class, interface, enum, or record expected
    data[i] = data[min];
    ^
Main.java:31: error: class, interface, enum, or record expected
    data[min] = change;
    ^
Main.java:32: error: class, interface, enum, or record expected
    count++;
    ^
Main.java:33: error: class, interface, enum, or record expected
  }
  ^
Main.java:36: error: class, interface, enum, or record expected
for(i = 0;i < num-1;i++){
          ^
Main.java:36: error: class, interface, enum, or record expected
for(i = 0;i < num-1;i++){
                    ^
Main.java:38: error: class, interface, enum, or record expected
}
^
Main.java:40: error: class, interface, enum, or record expected
printf("\n");
^
Main.java:41: error: class, interface, enum, or record expected
printf("%d",count);
^
Main.java:42: error: class, interface, enum, or record expected
printf("\n");
^
Main.java:43: error: class, interface, enum, or record expected
return 0;
^
Main.java:44: error: class, interface, enum, or record expected
}
^
29 errors