|
已知有关等差数列a1,an,d,n,sn中任意三个求另外两个
Define a.p()=
Prgm
:Local a1,an,d,n,sn,x1,x2
:RequestStr "请输入未知项1",x1,0
:RequestStr "请输入未知项2",x2,0
:If x1="a1" and x2="an" Then
: Request "公差d",d,0
: Request "项数n",n,0
: Request "前n项的和sn",sn,0
: a1:=((sn-d*n*((n-1)/(2)))/(n))
: an:=a1+(n-1)*d
: Disp "a1=",a1
: Disp "an=",an
: Stop
:EndIf
:If x1="an" and x2="a1" Then
: Request "公差d",d,0
: Request "项数n",n,0
: Request "前n项的和sn",sn,0
: a1:=((sn-d*n*((n-1)/(2)))/(n))
: an:=a1+(n-1)*d
: Disp "a1=",a1
: Disp "an=",an
: Stop
:EndIf
:If x1="a1" and x2="d" Then
: Request "第n项的值",an,0
: Request "项数n",n,0
: Request "前n项的和sn",sn,0
: a1:=((2*sn)/(n))-an
: d:=((an-a1)/(n-1))
: Disp "a1=",a1
: Disp "d=",d
: Stop
:EndIf
:If x1="d" and x2="a1" Then
: Request "第n项的值",an,0
: Request "项数n",n,0
: Request "前n项的和sn",sn,0
: a1:=((2*sn)/(n))-an
: d:=((an-a1)/(n-1))
: Disp "a1=",a1
: Disp "d=",d
: Stop
:EndIf
:If x1="a1" and x2="n" Then
: Request "第n项的值",an,0
: Request "公差d",n,0
: Request "前n项的和sn",sn,0
: Disp solve(system(a1=d*(n-1)-an,n=((sn)/(a1+((d*(n-1))/(2))))),a1,n)
: Stop
:EndIf
:EndPrgm当然还没完成,到这里我的最后一个If出错了,求教错在哪里,该怎么改 |
|