Advertisement
csetanzil

Untitled

Nov 9th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. /// Checking between two id is same or not
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. void decimal(int &);
  6. int test(int[],int []);
  7.  
  8. int main()
  9. {
  10.     int t,a[4],b[4],i,chk;
  11.     char c;
  12.     cin>>t;
  13.     for(i=0;i<t;i++)
  14.     {
  15.         cin>>a[0]>>c>>a[1]>>c>>a[2]>>c>>a[3];
  16.         cin>>b[0]>>c>>b[1]>>c>>b[2]>>c>>b[3];
  17.  
  18.         for(int j =0;j<4;j++)
  19.             decimal(b[j]);
  20.  
  21.         chk =test(a,b);
  22.         if(chk==1)
  23.             cout<<"Case "<<i+1<<": Yes"<<endl;
  24.         else
  25.             cout<<"Case "<<i+1<<": No"<<endl;
  26.     }
  27.     return 0;
  28. }
  29.  
  30. void decimal(int &n)
  31. {
  32.     int temp = n,i=0;
  33.     int sum = 0;
  34.     while(temp!=0)
  35.     {
  36.         sum = sum+((temp%10)*pow(2,i));
  37.         i++;
  38.         temp = temp/10;
  39.     }
  40.     n = sum;
  41. }
  42.  
  43. int test(int a[],int b[])
  44. {
  45.     if((a[0]==b[0])&&(a[1]==b[1])&&(a[2]==b[2])&&(a[3]==b[3]))
  46.        return 1;
  47.     else
  48.         return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement