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')==0){
    i++;
    }
    while((s[i]-'0')!=-1){
      printf("%c",s[i]);
    }
    printf("\n");
  }
}

Double click to view unformatted code.


Back to problem 609