Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.     int in, last = -1;
  5.     int count = 0, max_count = 0;
  6.     while(scanf("%d", &in) != EOF){
  7.         int lead = in, digits = 1;
  8.         while(lead/10 != 0){
  9.             lead /= 10;
  10.             digits ++;
  11.         }
  12.  
  13. #ifdef DEBUG
  14.         printf("last %d lead %d digits %d\n", last, lead, digits);
  15. #endif
  16.  
  17.         if(lead == last){
  18.             count += digits;
  19.         }
  20.         else{
  21.             if(count > max_count) max_count = count;
  22.             count = digits;
  23.         }
  24.         last = in%10;
  25.  
  26. #ifdef DEBUG
  27.         printf("count %d\n", count);
  28. #endif
  29.  
  30.     }
  31.     if(count > max_count) max_count = count;
  32.     printf("%d\n", max_count);
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement