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

WA C++ 1068. Summa
Posted by Necros 18 Oct 2013 22:59
what's wrong in my code:
#include <iostream>
int main()
{
    int N;
    std::cin >> N;
    int result=0;
    if (N=0){
        std::cout << 1 << std::endl;
        return 0;
    }
    if (N > 0)
    {
        for (int i=2; i<=N;i++)
        {
            result+=i;
        }
        std::cout << result << std::endl;
        return 0;
    }else
    {
        for (int i=-2;i >=N;i--)
        {
            result+=i;
        }
        std::cout << result << std::endl;
        return 0;
    }
    return 0;
}

Edited by author 18.10.2013 23:00