Pascal問題 誰參加了資訊學奧賽

2023-01-22 02:55:08 字數 1992 閱讀 5771

1樓:匿名使用者

var a,b,c,d,e:integer;

i:char;

begin

for a:=0 to 1 do

for b:=0 to 1 do

for c:=0 to 1 do

for d:=0 to 1 do

for e:=0 to 1 do

begin

if (a=1) and (b=0) thenf1:=1;

if (b+c=2) then

f2:=1;

if (c+d=1) then

f3:=1;

if (d+e=0) then

f4:=1;

if (e=1) and (a+d<2) thenf5:=1;

if (f1+f2+f3+f4+f5=0) thenfor i:='a' to 'e' do

if i=1 then write(i);

end;

end.

2樓:張哥

注:字元為1表示參加,為0 表示不參加,用『ord』判斷條件是否為真,若條件為真則返回值為1,為假則返回值為0;

var a,b,c,d,e:integer;

begin

for a:=0 to 1 do

for b:=0 to 1 do

for c:=0 to 1 do

for d:=0 to 1 do

for e:=0 to 1 do

if ord(((a=1) and (b=1)) or (a=0))+

ord(((b=1) and (c=0)) or ((b=0) and (c=1)))+

ord(((c=0) and (d=0)) or ((c=1) and (d=1)))+

ord((d=1) or (e=1))+

ord(((e=1) and (a=1) and (d=1)) or (e=0))=5 // 若五個條件都滿足則找到正確解;

then begin if a=1 then write('a');

if b=1 then write('b');

if c=1 then write('c');

if d=1 then write('d');

if e=1 then write('e');

end;

writeln;

end.

解釋得很清楚哦,相信你一定能看懂的。

3樓:傲絕天下間

begin

writeln('cd');

end.

4樓:夢中的搖籃

vara,b,c,d,e:integer;

begin

for a:=0 to 1 do

for b:=0 to 1 do

if ((a=1)and(b=1))or((a=0)and(b=1))or((a=0)and(b=0)) then

for c:=0 to 1 do

if b+c=1 then

for d:=0 to 1 do

if c+d<>1 then

for e:=0 to 1 do

if (d+e>0) then

if ((e=1)and(d=1)and(a=1))or((e=0)and(d=1)and(a=1))or((e=0)and(d=1)and(a=1))or((e=0)and(d=0)and(a=1))or((e=0)and(d=0)and(a=0)) then

begin

if a=1 then write('a');

if b=1 then write('b');

if c=1 then write('c');

if d=1 then write('d');

if e=1 then write('e');

writeln;

end;

end.

pascal簡單問題,pascal簡單問題一個。!

1.program aaa const eps 1e 7 varx,t,s real n integer begin read x n 1 t x s x repeat n n 2 t t x x n 1 n s s t until abs t writeln s end.2.program bbb...

pascal問題 5,pascal問題

pascal問題 它是下標變數,a是陣列名,i是下標。如要真正了解,需學習陣列型別。陣列的第i個元素 如 var a array 1.5 of integer begina 1 3 a 2 4 a 3 8 a 4 6 a 5 5 write a 3 end.就會輸出陣列a中的第3個元素8 陣列中的第...

PASCAL程式設計問題

因為機器上沒有安裝pascal,所以用delphi的控制檯來實現。62616964757a686964616fe78988e69d8331333330346531 var i,j longint r,s,t string temp char begin readln r readln s t s f...