C#实现:求表达式的值:1-2+3-4+……+m
static int Calculate(int m)
{
int result;
if (m % 2 == 0)
{
result = m / 2 * (-1);
}
else
{
result = m / 2 + 1;
}
return result;
}
{
int result;
if (m % 2 == 0)
{
result = m / 2 * (-1);
}
else
{
result = m / 2 + 1;
}
return result;
}
本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利
This posting is provided "AS IS" with no warranties, and confers no rights.
This posting is provided "AS IS" with no warranties, and confers no rights.
浙公网安备 33010602011771号