讨论 / 这样的想法为什么错?
swm 2013-01-18 00:19:00
点我顶贴 收藏 删除
var a:array[1..4] of real;

b:array[1..4] of string;

i1,i2,i3,i4,j,x,z,i,code:integer;

d1,d2,d3,o:real;

y1,y2:string;

Begin

read(b[1],b[2],b[3],b[4]);

for i:=1 to 4 do

if b[i]='A'

then

a[i]:=1

else

val(b[i],a[i],code);

o:=0;

for i1:=1 to 4 do

for i2:=1 to 4 do

for i3:=1 to 4 do

begin

j:=1;x:=2;

if i1=1 then d1:=a[j]+a[x];

if i1=2 then d1:=a[j]-a[x];

if i1=3 then d1:=a[j]*a[x];

if i1=4 then d1:=a[j]/a[x];

j:=3;

if i2=1 then d2:=a[j]+d1;

if i2=2 then d2:=a[j]-d1;

if i2=3 then d2:=a[j]*d1;

if i2=4 then d2:=a[j]/d1;

j:=4;

if i3=1 then d3:=a[j]+d2;

if i3=2 then d3:=a[j]-d2;

if i3=3 then d3:=a[j]*d2;

if i3=4 then d3:=a[j]/d2;

if d3=24 then o:=1;

end;

y1:='yes';y1:='no';

if o=1 then write('yes')

else write('no');

End.

查看更多回复
提交回复