Guest User

Untitled

a guest
Jan 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     const int max_int = 2147483647;
  7.     const int min_int = -max_int -1;
  8.     int a, b;
  9.  
  10.     cout<<"\n* Inserisci il primo numero: ";
  11.     cin>>a;
  12.     cout<<"* Inserisci il secondo numero: ";
  13.     cin>>b;
  14.  
  15.     cout<<"\n\tLa somma é: " <<a + b <<endl;
  16.     cout<<"\tOverflow: ";
  17.  
  18.     if ( ( a > 0 && b < 0 ) || ( a < 0 && b > 0 ) )
  19.     {
  20.         cout<<"NO" <<endl;
  21.         return 0;
  22.     }
  23.     if ( max_int - a > b && a > 0 ) || ( min_int - a > b && a < 0 )
  24.         cout<<"NO" <<endl;
  25.     else
  26.         cout<<"SI" <<endl;
  27.  
  28.     return 0;
  29. }
Add Comment
Please, Sign In to add comment