[ACM Timus] 1068. Sum [C]

Problem Link: 1068. Sum

 
[c]
#include<stdio.h>
int main()
{
int a,b,c,d;
scanf("%d",&a);
if(a>0)
b=a*(a+1)/2;
else{
d=0;
for(c=1;c>=a;c–){
d=d+c;
}
b=d;
}
printf("%d",b);
return 0;
}
[/c]

Advertisements