从1-1/2+1/3-1/4+1/5.....+1/100
1 回答
蜂之谷
TA贡献564条经验 获得超863个赞
double sum = 0; double sign = 1.0; for (int i = 1; i <= 100; i++) { sum += sign / i; sign = -sign; } System.out.println(sum);
添加回答
举报
0/150
提交
取消