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

Incorrect output ?
Posted by Martynas 30 Jan 2014 20:05
It keeps saying that my program produces incorrect solutions. Anyone else is having the same issue?

#include <stdlib.h>
#include <stdio.h>

int main() {
  int start, change, N, sum;
  scanf("%d", &N);
  if (abs(N) <= 10000) {
    change = N > 1 ? 1 : -1;
    for (start = 1; start != (N + change); start += change)
      sum += start;
    printf("%d\n", sum);
  }
  return 0;
}