代码:
1 import java.util.*; 2 public class Main { 3 public static void main (String [] args) { 4 int repeat,n; 5 Scanner s=new Scanner(System.in); 6 repeat=s.nextInt(); 7 for(int i=1;i<=repeat;i++) { 8 n=s.nextInt(); 9 double sum=0; 10 for(int j=1;j<=n;j++) { 11 sum+=1.0/j; 12 } 13 System.out.println(String.format("%.2f", sum)); 14 } 15 } 16 }
原文地址:https://www.cnblogs.com/fandehui/p/11042335.html
时间: 2024-10-10 01:47:10