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;
        }

posted on 2008-08-03 19:53  王丹小筑  阅读(1051)  评论(0)    收藏  举报

导航