add b.c
This commit is contained in:
parent
54b3348c1a
commit
487ec71873
1 changed files with 34 additions and 0 deletions
34
abc042/b.c
Normal file
34
abc042/b.c
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
Loading…
Reference in a new issue