主题:[color=FF0000]????????????????????????????????[/co
ewqaz
[专家分:0] 发布于 2006-02-11 18:54:00
用高精度求1!+2!+3!+…+n!(n〈=50)
[size=4]编出程序的++++++++++++30分[/size]
回复列表 (共1个回复)
沙发
lmj9201 [专家分:1400] 发布于 2006-02-13 12:22:00
const
maxn=66;
var
f,s:array[1..maxn] of integer;
i,j,k,g,n:integer;
begin
write('n=');
readln(n);
fillchar(f,sizeof(f),0);
fillchar(s,sizeof(f),0);
f[maxn]:=1;
for i:=1 to n do
begin
{f<-f*i}
g:=0;
for j:=maxn downto 1 do
begin
k:=f[j]*i+g;
f[j]:=k mod 10;
g:=k div 10;
end;
{s<-s+f}
g:=0;
for j:=maxn downto 1 do
begin
k:=s[j]+f[j]+g;
s[j]:=k mod 10;
g:=k div 10;
end;
end;
for j:=1 to maxn do
if s[j]<>0 then break;
for i:=j to maxn do
write(s[i]);
writeln;
end.
从别处贴来的,加个分
我来回复