Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- const int max_int = 2147483647;
- const int min_int = -max_int -1;
- int a, b;
- cout<<"\n* Inserisci il primo numero: ";
- cin>>a;
- cout<<"* Inserisci il secondo numero: ";
- cin>>b;
- cout<<"\n\tLa somma é: " <<a + b <<endl;
- cout<<"\tOverflow: ";
- if ( ( a > 0 && b < 0 ) || ( a < 0 && b > 0 ) )
- {
- cout<<"NO" <<endl;
- return 0;
- }
- if ( max_int - a > b && a > 0 ) || ( min_int - a > b && a < 0 )
- cout<<"NO" <<endl;
- else
- cout<<"SI" <<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment