现在的位置: 首页 > 综合 > 正文

1到100求和

2012年12月25日 ⁄ 综合 ⁄ 共 151字 ⁄ 字号 评论关闭
     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;
}

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

抱歉!评论已关闭.