View Code of Problem 609

#include <iostream>
using namespace std;

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

Double click to view unformatted code.


Back to problem 609