标签:blog offer mil 字符 min weight i++ 16px hit
1 bool compare(const string &st1,const string &st2) 2 { 3 string s1 = st1 + st2; 4 string s2 = st2 + st1; 5 return s1 < s2; 6 } 7 class Solution { 8 public: 9 const int g_MaxNumberLength=10; 10 string PrintMinNumber(vector<int> numbers) { 11 string result; 12 int length = numbers.size(); 13 if(length <= 0) 14 return result; 15 char** strNumbers=new char*[length]; 16 for(int i=0;i<length;i++) 17 { 18 strNumbers[i]=new char[g_MaxNumberLength+1]; 19 sprintf(strNumbers[i],"%d",numbers[i]); 20 } 21 sort(strNumbers,strNumbers+length,compare); 22 for(int i=0;i<length;i++) 23 result.append(strNumbers[i]); 24 25 for(int i=0;i<length;i++) 26 delete[] strNumbers[i]; 27 delete[] strNumbers; 28 return result; 29 } 30 };
标签:blog offer mil 字符 min weight i++ 16px hit
原文地址:http://www.cnblogs.com/qqky/p/6958780.html