发布网友 发布时间:2024-10-24 12:24
共1个回答
热心网友 时间:2024-11-09 11:48
class Calc{
int sum = 0;
float f;
public float calc(){
int j = 1;
for(int i = 1;i <=10;i ++){
f = j / i;
sum += f;
}
return sum;
}
public static void main(String args[]){
Calc c = new Calc();
System.out.println("1/1+1/2+1/3+…+1/10 的结果为:" + c.calc());
}
}