#include <stdio.h>
int main(){
int array[] ={4, 5, 3, 1,6,2,6,10,22,10,10};
for(int i = 0; i <= 10; i++){
for (int j = 0; j <= 9; j++){
printf("Array a[i] is %d\n", array[i]);
if(array[i] < array[j]){
// Swap
int temp;
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
printf("Array a[i,j] is %d %d\n", array[i],array[j]);
}
}
for (int i = 0; i <= 10; i++){
printf("%d", array[i]);
}
}
Could anyone check whether this sorting algorithm correct or not, because it seems to me that it does work. If it is correct, could you tell the name of this sorting algorithm please? Thank you!
I have tried to compile this code with different given output and it seems to me that it work just fine!