#include #include #define MAX 100001 void sort(char **arr, int n); int main(void) { char str[MAX]; int n; scanf("%d", &n); char *arr[n]; getchar(); // Get input char ch; int loc = 0; for (int i = 0; i < n; i++) { arr[i] = &str[loc]; while ((ch = getc(stdin)) != '\n') { str[loc++] = ch; } str[loc++] = '\0'; } sort(arr, n); for (int i = 0; i < n; i++) { printf("%s\n", arr[i]); } return 0; } void sort(char **arr, int n) { char *tmp; for (int i = 0; i < n; i++) { for (int j = 0; j < n - 1; j++) { if (strcmp(arr[j], arr[j + 1]) > 0) { tmp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = tmp; } } } }