ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1000. A+B Problem

where is the problem? thank you
Posted by Xiao Xiao 10 May 2008 20:38
#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
    int a,b;
    cout<<"please input integer a and b:";
    cin>>a>>b;
    if( cin.fail() )
    {
        cin.clear();
        cin.sync();
        cout<<"input error"<<endl;
        return -1;
    }

    int result = a + b;

    if( a > 0 && b > 0 )
    {
        if( result < 0 )
            cout<<"overflow"<<endl;
    }
    else if( a < 0 && b < 0 )
    {
        if( result > 0 )
            cout<<"overflow"<<endl;
    }

    cout<<result<<endl;

    return 0;
}

how can I get more wrong information?
Re: where is the problem? thank you
Posted by Dusan 1 Jun 2008 20:51
#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
int a,b;

cin>>a>>b;
cout<<a+b;
return 0;
}

you don't need to write mesages like .....cout<<"please input integer a and b:";.......your output must be only A+B