[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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s