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

What's wrong in this? (C++)
Posted by pbiiii 15 Feb 2013 14:53
#include <iostream>
//where is my mistake?
using namespace std;

int main()
{
    int number, result;
    cout << "Enter number: " << endl;
    cin >> number;
    result = number;
    if (number > 0 && number <= 10000)
    {
        for (int i = 1; i<number; i++)
        {
            result = result + i;
        }
    }

    else if (number <= 0 && number >= -10000)
    {
        for (int j = 1; j > number; j--)
        {
            result = result + j;
        }
    }
    else
    {
        cout << "Enter the number within the limits of [-10000;10000]" << endl;
        return main();
    }
    cout << "Otvet: " << result << endl;
    return 0;
}
Re: What's wrong in this? (C++)
Posted by Erik Kvam 25 Feb 2013 21:53


Edited by author 25.02.2013 22:28
Re: What's wrong in this? (C++)
Posted by Szenti 13 May 2013 20:53
You should not output any other text, only the solution.
Re: What's wrong in this? (C++)
Posted by stat958 25 Jun 2013 09:27
You shound't cout any extral words!
For example : not  cout << "Enter number: " << endl;
and change cout << "Otvet: " << result << endl; tocout << result << endl;