#include<stdio.h>
#include<stdlib.h>
#define MAX_SIZE 100001
void insert(int e, int a[], int i)
{
a[0]=e;
while(e < a[i])
{
a[i+1] =a[i];
i--;
}
a[i+1] = e;
}
void insertionSort(int a[], int n)
{
int j,temp;
for(j=2; j<=n; j++){
temp= a[j];
insert(temp, a, j-1);
}
}
void main(){
int a[MAX_SIZE];
int i,n;
scanf("%d" , &n);
for(i=1; i<=n; i++)
{
a[i] = n-i;
}
insertionSort(a, n);
printf("\n");
for(i=1; i<=n; i++)
{
printf("%d\t", a[i]);
}
}
'IT' 카테고리의 다른 글
퀵소트 시간 측정 (0) | 2014.06.09 |
---|---|
퀵소트 (0) | 2014.06.09 |
인설션 소트 시간 측정 (0) | 2014.06.09 |
소팅 시간 측정 (0) | 2014.06.09 |
런이라는 단어가 있는걸로 봐서 위너트리 (0) | 2014.06.09 |