-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path32.cpp
More file actions
42 lines (38 loc) · 681 Bytes
/
32.cpp
File metadata and controls
42 lines (38 loc) · 681 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
35
36
37
38
39
40
41
42
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
static bool cmp(int &a, int &b)
{
string aa = to_string(a);
string bb = to_string(b);
return (aa + bb) < (bb + aa);
}
string PrintMinNumber(vector<int> numbers)
{
string res;
sort(numbers.begin(), numbers.end(), cmp);
vector<int>::iterator it;
for (it = numbers.begin(); it != numbers.end(); it++)
{
int temp = *it;
res += to_string(temp);
}
return res;
}
int main()
{
ios::sync_with_stdio(false);
vector<int> v;
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
int temp;
cin >> temp;
v.push_back(temp);
}
cout << PrintMinNumber(v) << endl;
return 0;
}