Advertisement
JanevFilip

Untitled

May 29th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int broj_vo_broj(int br1,int br2)
  4. {
  5.     if(br1==0)
  6.     {
  7.         return 0;
  8.     }
  9.     int broj1 = br1;
  10.     int broj2=br2;
  11.     while ((broj1%10)==(broj2%10)&&broj2!=0)
  12.     {
  13.         broj1/=10;
  14.         broj2/=10;
  15.     }
  16.    
  17.     if (broj2==0)
  18.     {
  19.         return 1 + broj_vo_broj(broj1,br2);
  20.     }
  21.    
  22.         return 0 + broj_vo_broj(br1/10,br2);
  23.    
  24. }
  25.  
  26. int main()
  27. {
  28.     int n;
  29.     scanf("%d",&n);
  30.     while (n-- > 0)
  31.     {
  32.         int a,b;
  33.         scanf ("%d%d",&a,&b);
  34.         printf ("%d\n",broj_vo_broj(a,b));
  35.  
  36.     }
  37.    
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement