标签:find ade int ber last point out return elements
#include <iostream>
#include <string>
using namespace std;
void deleteDigite(int k, string str)
{
int len = str.length();
for(int i=0; i<k; i++) //there are k elements that need to be deleted
{
for(int j=0; j<len-1; j++) //the most times of cycles are len-1,if the second element is smaller than the previous,delete the first one, it is the great point
{
if(str[j]>str[j+1]) //if we meet the great point, we erase it
{
str.erase(j, 1);
len--;
break;
}
if(j==len-1) //if we arrive the end of string, but we did‘t find the element smaller than the previous one, the last one is a great point. erase it;
{
str.erase(j, 1);
}
}
}
cout << str;
}
int main()
{
string a = "1253879";
deleteDigite(2, a);
return 0;
}
tne number which is made of the number of remaining is smallest
标签:find ade int ber last point out return elements
原文地址:http://www.cnblogs.com/1915884031A-qqcom/p/7569160.html