class Program
{
//第一种(1-2)+(3-4)+(5-6)...+m
public static void Test(int m) {
int z = ;
if (m % == )
{
z = -(m / );
}
else {
z = -(m -) / + m;
}
Console.WriteLine(z);
}
//第二种1+(-2+3)+(-4+5)+(-6+7)...+m
public static void Test1(int m) {
int z = ;
if (m%==) {
z = (m - ) / +-m;
}
else {
z = (m - ) / + ;
}
Console.WriteLine(z);
}
static void Main(string[] args)
{
//第三种
int z = ;
for (var i = ; i < ; i++)
{
if (i % == )
{
z += i;
}
else
{
z += -i;
}
}
Test();
Test1();
Console.WriteLine(z);
Console.ReadLine();
}
}