/**
* 多项式求和
* 1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + ...
*/
import java.util.*;
public class acm2011{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while(in.hasNextInt()){
int n= in.nextInt();
for(int i = 0 ; i < n ; i++){
int a = in.nextInt();
int b= 1;
double sum = 0;
for(int j=1;j<=a; j++){
sum =sum+ b*(1.0/j);
b=b*(-1);
}
System.out.printf("%.2f",sum);
System.out.println();
}
}
}
}acm2011
原文:http://blog.csdn.net/a736933735/article/details/43882511