-1 +(-1)^2+....+(-1^n)
n为偶数和奇数
int sum2(int n)
{
int sum = 0;
if(n%2 == 0)
{
sum = 0;
}
else
{
sum = -1;
}
return sum;
}
int sum2(int n)
{
int sum = 0;
if(n%2 == 0)
{
sum = 0;
}
else
{
sum = -1;
}
return sum;
}