Advertisement
Semior001

ACMP_Task_2

Feb 13th, 2016
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4.     int n;
  5.     cin >> n;
  6.     long long sum = 0;
  7.     if(n<0){
  8.         for(int i = 1; i >= n; i--){
  9.             sum += i;
  10.         }
  11.     }
  12.     for(int i = 1; i <= n; i++){
  13.         sum+=i;
  14.     }
  15.     cout << sum << endl;
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement