#include <stdio.h>
int a[1000];
int n, i, j, temp, key;
int main() {
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for (i=0; i<n; i++)
    {
        key=a[i];
        for(j=i-1; j>=0 && key < a[j]; j--)//정렬된 배열=> key 값의 배열 앞부분
        {
            a[j+1]=a[j];
        }
        a[j+1]=key;
    }

    for (i=0; i<n; i++)
        printf("%d\n", a[i]);
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: