http://blog.csdn.net/hjh399/article/details/42641191
代码中间多了不应该存在的一些东西,为什么会出现?
求解答,谢谢各位。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
double sum = 0.0;
for (int i = 1;i <= n; i ++)
{
sum += 1.0/i;
}
System.out.println(sum);
System.out.printf( "%.2f",sum);
}
}