#include<stdio.h>
#include<stdlib.h>
#define SWAP(a,b,t)( (t)=(a), (a)=(b) , (b)=(t));
#define MAX_SIZE 100;
void selection_sort();
int main(void){
int i,n;
n = MAX_SIZE;
int arr[]={0};
for(i = 0; i<n; i++){
arr[i] = rand()%n;
}
selecton_sort(arr, n);
printf("---------------------------\n");
+
return 0;
}
void selection_sort(int *arr,int n){
int i,j,least,temp;
for( i=0 ; i<(n-1) ; i++){
least = i;
for ( j=i+1 ; j<n ; j++){
if(arr[j] < arr[least]) least = j;
SWAP(arr[i], arr[least], temp);
printf("%d ", arr[j]);
}
}
}
'이전것 > Algorithm' 카테고리의 다른 글
실습과제#2 (0) | 2014.09.26 |
---|---|
Insertion_Sort (0) | 2014.09.23 |
실습과제 #1 14 (0) | 2014.09.19 |
실습과제 #1 (0) | 2014.09.19 |
원을 만드는 것 (0) | 2014.09.12 |