-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path1198_Substring.cpp
More file actions
66 lines (61 loc) · 1.44 KB
/
Copy path1198_Substring.cpp
File metadata and controls
66 lines (61 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Problem#: 1198
// Submission#: 891865
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include<iostream>
#include<cstring>
using namespace std;
int t,n;
char str[100][100];
char outp[1000][100];
void sort();
int main()
{
cin>>t;
int k=0;
while(k<t)
{
cin>>n;
for(int i=0;i<n;i++)
cin>>str[i];
sort();
int j=0;
for(int i=0;i<n;i++)
{
int ii=0;
while(str[i][ii]!='\0')
{
outp[k][j]=str[i][ii];
ii++;
j++;
}
}
k++;
}
for(k=0;k<t;k++)
cout<<outp[k]<<endl;
return 0;
}
void sort()
{
for(int i=n-1;i>=0;i--)
{
for(int j=0;j<i;j++)
{
char c[100],d[100],e[100];
strcpy(c,str[j]);
strcpy(d,str[(j+1)]);
strcpy(e,c);
strcat(c,d);
strcat(d,e);
if(strcmp(c,d)>0)
{
char temp[100];
strcpy(temp,str[j]);
strcpy(str[j],str[(j+1)]);
strcpy(str[(j+1)],temp);
}
}
}
}