Help me in solving BMMC18 problem

My issue

My code

// Update the code below to solve the problem

#include <iostream>
#include <string>
using namespace std;

int main() 
{
 int t;
 cin>>t;
while(t--)
 { 
     int a,b;
     cin>>a>>b;
     if(a>b){
         cout<<7-a<<endl;
     }else if(b>a){
         cout<<7-b<<endl;
     }else{
         cout<<7-0<<endl;
     }
  }
 return 0;
}

Learning course: Solve Programming problems using C++
Problem Link: CodeChef: Practical coding for everyone

@shubhedu0112 the approach is to find the max of 2 numbers and then subtract that max number with 7.
here is the correct code below

hope this helps!!
include
include
using namespace std;

int main()
{
int t;
cin>>t;
while(t–)
{ int diff=0;
int a,b;
cin>>a>>b;
diff=max(a,b);
cout<<7-diff<<endl;
}
return 0;
}

1 Like