-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathF.cpp
More file actions
34 lines (30 loc) · 687 Bytes
/
F.cpp
File metadata and controls
34 lines (30 loc) · 687 Bytes
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
#include <iostream>
#include <string.h>
using namespace std;
void solve(){
string arr_num[100];
int i, j, count = 0;
for (int i = 0; i < 100; i++){
cin >> arr_num[i];
if (arr_num[i].size() == 0){
break;
}
count++;
}
for(i = count - 1; i > 0; i--){
for (j = 0; j < i; j++){
if (arr_num[j] + arr_num[j + 1] < arr_num[j + 1] + arr_num[j]){
swap(arr_num[j], arr_num[j + 1]);
}
}
}
for(int i = 0; i < count; i++){
cout << arr_num[i];
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
solve();
return 0;
}