View Code of Problem 609

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>

const int inf = (1<<31)-1;
const int MAXN = 1e3+10;

using namespace std;

char ts[MAXN];


int main()
{
    char mmin;
    int n,len,i;
    while(scanf("%s%d",ts,&n)!=EOF){
        len = strlen(ts);
        while(n--){
            mmin = ts[0];
            for(i=1;i<len;i++){
                if(mmin>ts[i]){
                    for(int j=i-1;j<len-1;j++){
                        ts[j] = ts[j+1];
                    }
                    break;
                }else{
                    mmin = ts[i];
                }
            }

            len--;
        }
        int flag= 0;
        for(i=0;i<len;i++){
            if(ts[i]=='0'&&!flag)continue;
            else{ printf("%c",ts[i]);flag = 1;}
        }
        if(!flag)cout<<0;
        cout<<endl;
    }
    //cout << "Hello world!" << endl;
    return 0;
}

Double click to view unformatted code.


Back to problem 609