发布网友
共4个回答
热心网友
【算法】用1,2,3,4,5分别代表百米、二百米、跳高、跳远和铅球5个项目,用a,b,c,d,e
分别代表五人。如b=3 表示乙获跳高冠军。用多重循环穷举出来。
【答案】甲 乙 丙 丁 戊
1 2 4 3 5
【参考程序】
var
a,b,c,d,e:byte;
begin
for a:=1 to 5 do
for b:=1 to 5 do
if a<>b then
for c:=1 to 5 do
if (a<>c) and (b<>c then
for d:=1 to 5 do
if (a<>d) and (b<>d) and (c<>d) then
begin
e:=15-a-b-c-d;
if (ord(b=5)+ord(d=3)=1) and
(ord(a=1)+ord(e=4)=1) and
(ord(c=4)+ord(d=2)=1) and
(ord(b=3)+ord(e=5)=1) then
writeln('a:',a,'b:',b,'c:',c,'d:',d,'e:',e);
end;
end.
热心网友
第一题:
var
a:real;
i:longint;
begin
while x<22 then begin
inc(i);x:=x*1.015; end;
writeln(i);
end.
热心网友
2.(算法分析)
用1,2,3,4,5分别代表百米、二百米、跳高、跳远和铅球5个项目,用a,b,c,d,e 分别代表五人。如b=3 表示乙获跳高冠军。用多重循环穷举出来。
(参考程序)
var a,b,c,d,e:byte;
begin
for a:=1 to 5 do
for b:=1 to 5 do
for c:=1 to 5 do
for d:=1 to 5 do
e:=15-a-b-c-d;
if (ord(b=5)+ord(d=3)=1) and
(ord(a=1)+ord(e=4)=1) and
(ord(c=4)+ord(d=2)=1) and
(ord(b=3)+ord(e=5)=1) and
(a*b*c*d*e=120) then
writeln ('a:',a,'b:',b,'c:',c,'d:',d,'e:',e);
end.
热心网友
【算法】用1,2,3,4,5分别代表百米、二百米、跳高、跳远和铅球5个项目,用a,b,c,d,e
分别代表五人。如b=3 表示乙获跳高冠军。用多重循环穷举出来。
【答案】甲 乙 丙 丁 戊
1 2 4 3 5
【参考程序】
program 妈妈咪妈咪妈咪;
var
a,b,c,d,e:byte;
begin
for a:=1 to 5 do
for b:=1 to 5 do
if a<>b then
for c:=1 to 5 do
if (a<>c) and (b<>c then
for d:=1 to 5 do
if (a<>d) and (b<>d) and (c<>d) then
begin
e:=15-a-b-c-d;
if (ord(b=5)+ord(d=3)=1) and
(ord(a=1)+ord(e=4)=1) and
(ord(c=4)+ord(d=2)=1) and
(ord(b=3)+ord(e=5)=1) then
writeln('a:',a,'b:',b,'c:',c,'d:',d,'e:',e);
end;
end.