SRM 583 Div II Level One:SwappingDigits

题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12609

#include <iostream>
#include <string> using namespace std; string minstr = ""; class SwappingDigits
{
public: string minNumber(string num);
}; string SwappingDigits::minNumber(string num)
{
string temp;
string mins = "";
for (int i = 0; i < num.size()-1; i++) {
for (int j = i+1; j < num.size(); j++) {
temp = num;
swap(temp[i], temp[j]);
if (temp[0] != '0' && mins == "") {
mins = temp;
} else {
if (temp[0] != '0' && temp < mins) {
mins = temp;
}
}
}
} return mins;
}
上一篇:【EatBook】-NO.3.EatBook.3.JavaArchitecture.2.001-《架构探险:从零开始写Java Web框架》-


下一篇:[ 转]Node.js模块 require和 exports