tne number which is made of the number of remaining is smallest

Posted diamondDemand

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tne number which is made of the number of remaining is smallest相关的知识,希望对你有一定的参考价值。

#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的主要内容,如果未能解决你的问题,请参考以下文章

MySQL - java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0)

解决java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).

解决java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).

解决java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).

InsecureRequestWarning: Unverified HTTPS request is being made.解决方法

InsecureRequestWarning: Unverified HTTPS request is being made