Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <stdio.h>
int main()
{
int i, j, position, tausch;
int arr[] = {5, 12, 6, 3, 7};
int arr_groesse = sizeof(arr) / sizeof(arr[0]);
for(i = 0; i < arr_groesse - 1; i++){
position = i;
for(j = i + 1; j < arr_groesse; j++){
if(arr[position] > arr[j])
position = j;
}
if(position != i){
tausch = arr[i];
arr[i] = arr[position];
arr[position] = tausch;
}
}
printf("Sortiertes Array:\n");
for(i = 0; i < arr_groesse; i++){
printf("%d ", arr[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.