Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <iostream>
  4. #include <algorithm>
  5. using namespace std;
  6. long double n;
  7. int main()
  8. {
  9. scanf("%lf",&n);
  10. if(n>0) {
  11.  
  12. printf("%.0lf\n",((1+n)/2)*n);
  13. }
  14. else {
  15.  
  16. printf("%.0lf\n",(((1+-n)/2)*n)+1);
  17. }
  18. system("pause");
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement