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

Problem 1068 mystery
Posted by Malyshev Fedor 2 Sep 2001 01:30
I don't know why I always get "wrong answer" for submitting
my pascal program, solving this problem. I'd be pleased if
someone will give me code, that solves it (I'm just curious
what is wrong in my program).
Re: Problem 1068 mystery
Posted by GoGo 3 Sep 2001 01:56
> I don't know why I always get "wrong answer" for
submitting
> my pascal program, solving this problem. I'd be pleased
if
> someone will give me code, that solves it (I'm just
curious
> what is wrong in my program).
Here is my source : (C++)

#include <stdio.h>

int i;long sum=0;
int n;

void main()
 {
  scanf("%d",&n);
  if(n<1)
   for(i=1;i>=n;i--)
    sum+=i;
  else
   for(i=1;i<=n;i++)
    sum+=i;
  printf("%ld",sum);
 }