View Code of Problem 609

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

Double click to view unformatted code.


Back to problem 609