OK so I have a program that when I run it with the provided test data, it seems fine. But when I submit the code, it says incorrect answer.
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int reverse(int input)
{
int output = 0;
while (input > 0)
{
output = (output * 10) + (input % 10);
input = input / 10;
}
return output;
}
int main(int argc, char* argv[])
{
int val1, val2;
string input;
for (int i = 0; i != 10000; i++)
{
val1 = 0; val2 = 0;
getline(cin, input);
stringstream ss(input);
ss >> val1;
ss >> val2;
if(val1 > 0 && val2 > 0)
cout<<reverse((reverse(val1) + reverse(val2)))<<endl;
}
return 0;
}