郑州轻工业大学OJ:java1040
作者:互联网
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int n;
int i=0;
double a=-1;
double s=0;
Scanner in=new Scanner(System.in);
n=in.nextInt();
while(i<n) {
i=i+1;
a=a+2;
s=1/a+s;
}
System.out.println(String.format("%.2f", s));
}
}
标签:Scanner,int,double,System,OJ,String,java1040,public,轻工业 来源: https://blog.csdn.net/weixin_45065220/article/details/91126587