Topcoder SRM 583 DIV2 SwappingDigits

题目题意是交换一次,使数字最小,且数字前面不能有前导0

    string minNumber(string num)
{
string res = num;
for(int i = 0 ; i < num.size(); i ++ ){
for(int j = i + 1; j < num.size(); j ++ ){
if(i == 0 && num[j] == '0') continue;
else{
swap(num[i],num[j]);
res = res > num ? num : res;
swap(num[i],num[j]);
}
}
}
return res;
}

  

上一篇:js作用域的一个小例子


下一篇:纯Python综合图像处理小工具(3)10种滤镜算法