ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1068. Sum

why not right&
Posted by legik 6 May 2011 16:41
#include <iostream>
using namespace std;

int main()
{
    int n;
    int sym=0;
    int znak;
    cin>>n;

    n>0?znak=1:znak=-1;
    n=abs(n);
    for (int i=2;i<=n;i++)
        sym+=i;
    cout<<sym*znak;
    cin>>n;
    return 0;
}
Re: why not right&
Posted by AterLux 6 May 2011 18:51
try by yourself
input (output)
1 (1)
0 (1)
-1 (0)
-2 (-2)