REMISS_Wrong_Answer

I am unable to debug my code according to the sample input am getting the desired output but on submitting my code am getting a wrong answer…Please can someone help me out here…
#include
#include
using namespace std;

int main() {

cin.tie(NULL);
ios_base::sync_with_stdio(false);
cout.tie(NULL);

int t,mini,maxi;
int a,b;
cin>>t;
while(t--){
    cin>>a>>b;
    mini=(a>=b)?a:b;
    maxi=a+b;
    }
    cout<<mini<<" "<<maxi<<"\n";
return 0;

}

question link?

There are test cases. You are printing the output outside the loop. So the mini and maxi values are not getting updated after every test case. So, instead print them inside.

while(t--){
cin>>a>>b;
    mini=(a>=b)?a:b;
    maxi=a+b;
   count<<mini<<" "<<maxi<<"\n";
}

Try this…
Your code is printing the result only for the last testcase…

1 Like

i misplaced the braces… Thank you so much!

Yeah I just realised I misplaced the braces… Thank you so much!

2 Likes