This commit is contained in:
mallowday 2024-02-01 11:16:15 +09:00
parent 3ad0a253c6
commit 0f49a1ebae

View file

@ -2,33 +2,33 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
int compare_strings(const void *string1, const void *string2); int cmp_str(const void *str1, const void *str2);
int main(void) int main(void)
{ {
int i; int i;
int number_strings; int num;
int string_length; int len;
char strings[100][100 + 1]; char strs[100][100 + 1];
scanf("%d %d", &number_strings, &string_length); scanf("%d %d", &num, &len);
i = 0; i = 0;
while (i < number_strings) while (i < num)
{ {
scanf("%s", strings[i]); scanf("%s", strs[i]);
++i; ++i;
} }
qsort(strings, number_strings, sizeof(strings[0]), compare_strings); qsort(strs, num, sizeof(strs[0]), cmp_str);
i = 0; i = 0;
while (i < number_strings) while (i < num)
{ {
printf("%s", strings[i]); printf("%s", strs[i]);
++i; ++i;
} }
puts(""); puts("");
} }
int compare_strings(const void *string1, const void *string2) int cmp_str(const void *str1, const void *str2)
{ {
return (strcmp(string1, string2)); return (strcmp(str1, str2));
} }