---
# System prepended metadata

title: 12099 - String sorting
tags: [NTHUOJ]

---

# 12099 - String sorting
## 題解:
用Bubble Sort的話, 最後一筆測資會TLE
所以要使用qsort
能不用Bubble Sort就不用, 因為複雜度為O(N^2)
## Code:
```c=1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char s[200005][105];

int cmp(const void *a,const void *b){
    return strcmp((char*)a, (char*)b);
}

int main(){
    int len = 0;
    while(scanf("%s", s[len]) != EOF)
        len++;
    qsort(s, len, sizeof(char) * 105, cmp);
    for(int i = 0; i < len; i++)
        printf("%s\n", s[i]);
    return 0;
}
```
###### tags: `NTHUOJ`