3 / 3
Jul 2019

please help .

###1. why is the code not working inspite of being simple in logic and implementation
##2. how will i check all the test cases for big numbers, how to find the answer… i mean to even check if the compiler gives correct answer. what should we do in problems like these?

int main() {

// your code here
for(int i=0;i<10;i++)
{
	int sum;
	int diff;
	cin>>sum>>diff;
	int k=(sum+diff)/2;
	cout<<k<<endl;
	cout<<(sum-k)<<endl;
}

return 0;

}

  • created

    Jun '19
  • last reply

    Jul '19
  • 2

    replies

  • 952

    views

  • 3

    users

I suspect you already know that the answer to question 1 is given in question 2.

Big numbers are the real problem here. You have choices - use a language that handles big numbers natively, such as Python. Or use one that provides a big number library - I think some dialects of C++ do, and perhaps Java. Or write some methods to do simple math on big numbers stored as strings or arrays.

Of course, this last option is the most challenging and interesting.