#include
#include
#include
#include
#include
using namespace std;
int main()
{
string str;
cin >> str;
int len = str.size(),
i = 0,
j = 0; // 第一个非数字位置
for (; i < len && j < len; )
{
while (j < len && isdigit(str[j]))
{
j++;
}
i = j;
while (i < len && !isdigit(str[i]))
{
i++;
}
if (i < len && j < len)
{
swap(str[j],str[i]);
i++;
j++;
}
}
sort(str.begin(),str.begin() + j,greater());
for (int i = 0; i < j; i++)
{
cout<}
//cout<return 0;
}
// 5_19.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include
#include
#include
#include
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "请输入字符: ";
std::string input;
std::cin >> input;
std::vector
if (!input.empty())
{
for (unsigned i = 0; i < input.size(); ++i)
{
if ((input[i] >= '0') && (input[i] <= '9'))
number.push_back(input[i]);
}
}
else
{
std::cout << "Error" << std::endl;
}
std::sort(number.begin(), number.end());
for (std::vector
{
std::cout << *it << std::endl;
}
return 0;
}
写的比较仓促,细节上可能有点问题