View Code of Problem 609

#include<iostream>
#include<stdio.h>
#include<string>
#include<cstring>
#include<string.h>
#include<algorithm>
using namespace std;

int main() {
	string s;
	while (cin >> s) {
		int n;
		cin >> n;
		while (n--) {
			int i=0;
			for (i = 0;i < s.length();i++) {
				if (i==s.length()-1||s[i] > s[i + 1]) {
					s.erase(i, 1);
					break;
				}
			}
		}

		while (s[0] == '0') {
			s.erase(0, 1);
		}

		if (s[0] != NULL) {
			cout << s << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
}

Double click to view unformatted code.


Back to problem 609