slider

还是菜鸟
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

1到100求和

Posted on 2012-02-09 17:43  slider  阅读(275)  评论(0编辑  收藏  举报
     private static int getSum(int start,int end){
int n=0;
int temp = start+end;
while(end>start){
n+=temp;
start++;
end--;
}
if(end==start)
n+=start;
return n;
}

听别人说的一个笔试题,弄了下