deadinside1222

sirius1

Oct 28th, 2021
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a;
  8.     int n;
  9.     cin >> a;
  10.     cin >> n;
  11.  
  12.     if (n > 0)
  13.     {
  14.         //cout << a + abs(n);
  15.         if(a<0 && a + abs(n) >0)
  16.         {
  17.             cout << a + abs(n) + 1;
  18.         }
  19.     }
  20.     else
  21.     {
  22.         //cout << a- abs(n);
  23.         if (a > 0 && a - abs(n) < 0)
  24.         {
  25.             cout << a - abs(n) - 1;
  26.         }
  27.     }
  28.     if( n == 0 )
  29.     {
  30.     cout <<  a;
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment