From 487ec7187364844a85e5846888ccffb3d3d691c4 Mon Sep 17 00:00:00 2001 From: mallowday Date: Wed, 31 Jan 2024 17:15:04 +0900 Subject: [PATCH] add b.c --- abc042/b.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 abc042/b.c diff --git a/abc042/b.c b/abc042/b.c new file mode 100644 index 0000000..08470ed --- /dev/null +++ b/abc042/b.c @@ -0,0 +1,34 @@ +#include +#include +#include + +int compare_strings(const void *string1, const void *string2); + +int main(void) +{ + int i; + int number_strings; + int string_length; + char strings[100][100 + 1]; + + scanf("%d %d", &number_strings, &string_length); + i = 0; + while (i < number_strings) + { + scanf("%s", strings[i]); + ++i; + } + qsort(strings, number_strings, sizeof(strings[0]), compare_strings); + i = 0; + while (i < number_strings) + { + printf("%s", strings[i]); + ++i; + } + puts(""); +} + +int compare_strings(const void *string1, const void *string2) +{ + return (strcmp(string1, string2)); +}