program a1;
var i,n,a:longint;
s:real;
begin
readln(n);
a:=1;
for i:=1 to n do
begin
s:=s+a*(1/i);
a:=-a;
end;
writeln(s:2:5); {取两位整数,保留6位小数}
end.
自己写的
program a1;
var i,n,a:longint;
s:real;
begin
readln(n);
a:=1;
for i:=1 to n do
begin
s:=s+a*(1/i);
a:=-a;
end;
writeln(s:2:5); {取两位整数,保留6位小数}
end.
自己写的