sicily 1783. Large is Better

水题一道.....


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

bool cmp(char str1, char str2)
{
	return str1 > str2;
}

int main()
{
	int caseNum;
	int caseCount = 0;

	string number;

	cin >> caseNum;

	while (caseCount < caseNum)
	{
		cin >> number;

		for (int i = 0; i < number.length(); i++)
		{
			if (number[i] != '0')
			{
				int startSortIndex = i;
				int sortIndexCount;
				while (true)
				{
					if (i > number.length() - 1 || number[i] == '0')
						break;
					else
					{
						i++;
					}
				}
				sort(number.begin() + startSortIndex, number.begin() + i, cmp);
			}
		}

		cout << number << endl;

		caseCount++;
	}
}


你可能感兴趣的:(String)