主题:那位高手指点一下啊!
各位高手,帮我回答一个问题吧!
以下是一道书上的题目。可是却运行不了啊!
program intege(input,output);
var
s1,s2:real;
function f1(x:real):real;
begin
f1:=1/(1+x);
end;
function f2(x:real):real;
begin
f2:=x*exp(-x*x);
end;
[color=FF00FF]function simpson(function f(x:real):real;a,b:real):real;
const[/color] n:=40;
var
h,s:real;
i:integer;
begin
h:=(b-a)/n;
s:=f(a)+f(b);
for i:=1 to n-1 do
if odd(i)
then s:=s+4*(a+i*h)
else s:=s+2*(a+i*h);
simpson:=h/3*s
end;
begin
s1:=simpson(f1,0,1);
s2:=simpson(f2,1,2.5);
writeln('s1=',s1,'s2=',s2)
end
运行的时候说那个simpson程序处missmatch!
能有高手指教指教吗?.(好像是这种不合乎标识符的啊!为什么啊!帮帮忙啊!)
以下是一道书上的题目。可是却运行不了啊!
program intege(input,output);
var
s1,s2:real;
function f1(x:real):real;
begin
f1:=1/(1+x);
end;
function f2(x:real):real;
begin
f2:=x*exp(-x*x);
end;
[color=FF00FF]function simpson(function f(x:real):real;a,b:real):real;
const[/color] n:=40;
var
h,s:real;
i:integer;
begin
h:=(b-a)/n;
s:=f(a)+f(b);
for i:=1 to n-1 do
if odd(i)
then s:=s+4*(a+i*h)
else s:=s+2*(a+i*h);
simpson:=h/3*s
end;
begin
s1:=simpson(f1,0,1);
s2:=simpson(f2,1,2.5);
writeln('s1=',s1,'s2=',s2)
end
运行的时候说那个simpson程序处missmatch!
能有高手指教指教吗?.(好像是这种不合乎标识符的啊!为什么啊!帮帮忙啊!)