Plabon_dutta

Uva 11687 (1)

Mar 2nd, 2021 (edited)
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include<math.h>
  4.  
  5. int function(int l, int c);
  6.  
  7. int main() {
  8.     char str[1000010];
  9.     while(1) {
  10.         scanf("%s", &str);
  11.         if(strcmp(str,"END")==0) break;
  12.         if(strcmp(str, "1")==0) printf("1\n");
  13.         else printf("%d\n", function(strlen(str),1));
  14.     }
  15.     return 0;
  16. }
  17.  
  18. int function(int l, int c) {
  19.     if (l == 1)
  20.         return c + 1;
  21.  
  22.     int nl=0, oldLength(length);
  23.  
  24.     for (; l>0; l/= 10) nl++;
  25.  
  26.     return function(nl, c + 1);
  27. }
  28.  
Add Comment
Please, Sign In to add comment