#include<iostream> using namespace std; int main(){ string str; int n; while(cin>>str>>n){ while(n--){ for(int i=0;i<str.length();i++){ if((str[i]>str[i+1])||i==str.length()-1){ // 删除左右位最大的或者是最右边是最大的情况 str.erase(i,1); break; } } } while(str[0]=='0'){ // 在有效数字前的0是无效的 删除 str.erase(0,1); } if(str[0] !=NULL){ cout<<str<<endl; }else{ cout<<0<<endl; } } } |
Double click to view unformatted code.