/C06032 - Ghép xâu
<Problem>
https://code.ptit.edu.vn/student/question/C06032#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define max(i, j) ((i > j) ? i : j)
bool Kompare(char s1[200], char s2[200]) {
char a[200];
char b[200];
strcpy(a, s1);
strcpy(b, s2);
strcat(a, b);
strcat(b, a);
if (strcmp(a, b) < 0) return false;
return true;
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
char s[200][200];
for (int i = 0; i < n; i++) scanf("%s", s[i]);
for (int i = 0; i < n - 1; i++) {
for (int j = n - 1; j > i; j--) {
if (Kompare(s[j], s[j - 1]) == false) {
char c[200];
strcpy(c, s[j]);
strcpy(s[j], s[j - 1]);
strcpy(s[j - 1], c);
}
}
}
for (int i = 0; i < n; i++) printf("%s", s[i]);
printf("\n");
}
return 0;
}