View Code of Problem 609

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

Double click to view unformatted code.


Back to problem 609