-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
45 lines (34 loc) · 674 Bytes
/
main.cpp
File metadata and controls
45 lines (34 loc) · 674 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
43
44
45
#include <string>
#include <vector>
#include <algorithm>
using std::string;
using std::vector;
bool Compare(string lhs, string rhs)
{
string tmp1 = lhs + rhs;
string tmp2 = rhs + lhs;
return tmp1 < tmp2;
}
string PrintMinNumber(vector<int> numbers) {
string str;
vector<string> vec;
if (numbers.size() > 0)
{
for (int i = 0; i < numbers.size(); ++i)
{
char tmp[10] = { 0 };
sprintf_s(tmp, "%d", numbers[i]);
std::string tmpStr(tmp);
vec.push_back(tmpStr);
}
std::sort(vec.begin(), vec.end(), Compare);
for (int i = 0; i < vec.size(); ++i)
str += vec[i];
}
return str;
}
int main()
{
PrintMinNumber({ 3,32, 321 });
return 0;
}