View Code of Problem 609

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

Double click to view unformatted code.


Back to problem 609