题解 | #牛牛学数列#
牛牛学数列
http://www.nowcoder.com/practice/0b97367cd2184c12a0e02f7c223aee11
int main()
{
int n = 0;
scanf("%d",&n);
int i = 0;
int sum = 0;
for(i = 1;i<=n;i++)
{
if(i%2==0)//偶数
{
sum = sum-i;
}
else
{
sum = sum+i;
}
}
printf("%d",sum);
return 0;
}