Advertisement
damch

pokl br

Dec 24th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int povtoruvanje(int a,int b){
  5.  
  6. if (a==0&&b==0)
  7. return 0;
  8. else{
  9. if(a%10==b%10)
  10. return 1+povtoruvanje(a/10,b/10);
  11. else return povtoruvanje(a/10,b/10);
  12. }
  13. }
  14.  
  15.  
  16. int main()
  17. {
  18. int a,b;
  19. int n;
  20. scanf("%d",&n);
  21. int i;
  22. int cuvaj;
  23.  
  24. for(i=1;i<=n;i++)
  25. {
  26. int brcifri=0;
  27. scanf("%d %d",&a,&b);
  28. if (a>=b){
  29. cuvaj=a;
  30. while(cuvaj>0)
  31. {
  32. brcifri++;
  33. cuvaj/=10;
  34. }
  35. }
  36. else if(b>a){
  37.  
  38. cuvaj=b;
  39. while(cuvaj>0)
  40. {
  41. brcifri++;
  42. cuvaj/=10;
  43. }
  44. }
  45. int l=povtoruvanje(a,b);
  46. printf("%.2f%%\n",(l/(float)brcifri)*100);
  47. }
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement