View Code of Problem 609

#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	while(cin>>s){
		int n;cin>>n;
		while(n--){
			int i;
			for(i=0;i<s.size()-2;++i)
				if(s[i]>s[i+1])
				break;
			if(i==s.size()-2)
			i++;
			s.erase(i,1);
		}
		for(int i=0;i<s.size();){
			if(s[i]=='0')
			s.erase(i,1);
			else
			break;
		}
		if(s.size()==0)
		cout<<0<<endl;
		else
		cout<<s<<endl;
	}
}

Double click to view unformatted code.


Back to problem 609