Advertisement
saira12tabassum19

Untitled

Sep 28th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int decimal(int num)
  4. {
  5. int temp=num,sum=0,base=1;
  6. while(temp!=0)
  7. {
  8. num=temp%10;
  9. temp=temp/10;
  10. if(num!=0&&num==1)
  11. {sum=sum+num*base;}
  12. base=base*2;
  13.  
  14. }
  15. return sum;
  16. }
  17. int main()
  18. {
  19. int T;
  20. cin>>T;
  21. int A,B,c,d;
  22. for(int i=0;i<T;i++)
  23. {
  24. cin>>A>>B;
  25. c=decimal(A);
  26. d=decimal(B); //cout<<c<<' '<<d<<endl;
  27. if(c==d)cout<<"Case "<<i+1<<": Same"<<endl;
  28. else if(c>d)cout<<"Case "<<i+1<<": A"<<endl; //Case 1: A
  29. else if(d>c)cout<<"Case "<<i+1<<": B"<<endl;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement