|
|
back to boardDiscussion of Problem 1068. Sum1068 Posted by Navid 20 Feb 2016 21:12 Why does it keep saying wrong answer? #include<stdio.h> #include<math.h> int main() { int num,element_no;
double sum;
scanf("%d",&num);
if(num<0)
{ element_no = fabs(num) + 2;
}
else
{ element_no = num; }
sum = (element_no/2.0) * (num + 1) ;
int ans = sum; printf("%d\n",ans);
return 0; } |
|
|