Advertisement
rengetsu

Timus_1068

Jul 20th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. //Timus 1068
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n, answ=0;
  7.     cin >> n;
  8.     if(n<0)
  9.     {
  10.         for(int i=n;i<2;i++)
  11.         {
  12.             answ+=i;
  13.         }
  14.         cout << answ;
  15.     }
  16.     else if(n==0){cout<<"1";}
  17.     else if(n==1){cout<<"1";}
  18.     else
  19.     {
  20.         for(int i=n;i>0;i--)
  21.         {
  22.             answ+=i;
  23.         }
  24.         cout << answ;
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement