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