View Code of Problem 609

    #include <stdio.h>
    #include <string.h>
    int main(){
      char s[1000];
      int n;
      while(scanf("%s",s)!=EOF){
        int len =strlen(s);
        scanf("%d",&n);
        int i=0;
        while(n--){
          if(s[i]>s[i+1]){ 
            s[i]=-1;
          }
          i++;
          if(i==len){
            i=0;
          }
        }
        i=0;
        while(s[i]=='0'){
        i++;
        }
        if(i<len){
          while(s[i]!=-1){
            printf("%c",s[i]);
            i++;
          }
        }else  printf("0");
        
        printf("\n");
      }
    }

Double click to view unformatted code.


Back to problem 609