package lianxiyi;
import java.util.Scanner;
public class T5 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println ("请输入一个数repeat");
Scanner input=new Scanner(System.in);
int repeat =input.nextInt();
System.out.println("请输入"+repeat+"组的");
int []a=new int[repeat];
for(int i=1;i<=repeat;i++){
a[i]=input.nextInt();
float sum=0;
int temp=1;
for(int m=1;m<=a[i];m++){
sum=sum+1/m;
temp=temp+2;
}
System.out.print("sum的值为"+sum);
}
}}
sum的值就只能等于1啊 为什么呀
import java.util.Scanner;
public class T5 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println ("请输入一个数repeat");
Scanner input=new Scanner(System.in);
int repeat =input.nextInt();
System.out.println("请输入"+repeat+"组的");
int []a=new int[repeat];
for(int i=1;i<=repeat;i++){
a[i]=input.nextInt();
float sum=0;
int temp=1;
for(int m=1;m<=a[i];m++){
sum=sum+1/m;
temp=temp+2;
}
System.out.print("sum的值为"+sum);
}
}}
sum的值就只能等于1啊 为什么呀