#include <stdio.h>
void selectSort(int arr2[],int len){
for (int i = 0; i < len - 1;i++) {
for (int j = i + 1; i < len; j++) {
if (arr2[i] > arr2[j]) {
int temp = arr2[i];
arr2[i] = arr2[j];
arr2[j] = temp;
}
}
}
}
int main(int argc, const char * argv[]) {
int a2[10] = {23,12,4,67,20,100,21,45,3,28};
for (int i = 0; i < 10; i++) {
printf("%d\t",a2[i]);
}
selectSort(a2, 10);
for (int i = 0; i < 10; i++) {
printf("%d\t",a2[i]);
}
return 0;
}
|
|