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

В чем проблема?(
Posted by DeDaRm 10 Nov 2013 23:03
#include <iostream>
using namespace std;

int main ()
{
    int x,y=0;
    cin >> x;
    if (x==1)
    {
        cout << x-1;
        return 0;
        system ("pause > void");
    }
    if (x>1 && x<=10000)
    {
        for (int z=1;z<=x;++z)
        {
            y+=z;
        }
    }
    if (x<1 && x>=-10000)
    {
        for (int z=x;z<=1;++z)
        {
            y+=z;
        }
    }
    cout << y;
    system ("pause > void");
}

Edited by author 10.11.2013 23:05
Re: В чем проблема?(
Posted by morbidel 15 Nov 2013 17:27
For x=1 your output is wrong; why do you print x-1?
Re: В чем проблема?(
Posted by DeDaRm 15 Nov 2013 18:47
ok,THX)) if x=1,cout x or 1

Edited by author 15.11.2013 18:51