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;
}
 
 
 
                    
                

 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号