View Code of Problem 609

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstring>
using namespace std;
int main()
{
	char a[1000];
	while(scanf("%s",&a)!=EOF){
		int x=strlen(a);
		int n;
		cin>>n;
		while(n--){
			 int i=0;
			 while(a[i]<=a[i+1]&&i<x)
			 {
			 	i++;
			  }
			  for(int j=i;j<x-1;j++){
			  	a[j]=a[j+1];
			  } 
			  --x;
		}
		int k=0;
		while(a[k]=='0'){
			k++;
		}
		if(k<x){
			for(int i=k;i<x;i++)
			{
				cout<<a[i];
			}
		}else{
			cout<<"0";
		}
		cout<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 609