#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//* qsort (주소, 배열길이, 한 배열의 크기, compare)
//* qsort (arr, n, sizeof(arr), compare)
//* compare(void *a, void *b) 입력이 뭐로 올지 모르기때문에 void 주소로 받고
// 나중에 형 변환 함 ex) int 면 int num1=*(int*)a; 이런 느낌
// return 값이 양수면 왼쪽이 큰거 아니면 반대 그래서 return n1-n2로 간단하게

//strcmp(*arr,*arr) 문자열 비교 사전순으로 이거도 왼쪽이 크면 양수 return
// 같으면 0 return 



int compare(const void *a, const void *b) {
    int num1= strlen((char*)a);
    int num2= strlen((char*)b);
    if (num1!=num2) return num1-num2;
    return strcmp((char*)a, (char*)b); 
}

int main() {
    int n;
    char word[20001][51]={0};
    scanf("%d",&n);
    for(int i=0; i<n; i++) {
        scanf("%s",word[i]);
    }

    qsort(word, n, sizeof(word[0]),compare);
    for(int i=0; i<n; i++) {
        if (i==n-1) {
            printf("%s\n",word[i]);
            break;
        }
        if (strcmp(word[i],word[i+1])!=0 ) printf("%s\n",word[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: