pascal語言程式設計題求高手呀追加跪求進來看一看

時間 2022-02-08 04:15:06

1樓:哀傷_無限

答案不唯一,abc/ab/ac都是答案

vari1,i2,i3,j:longint;

begin

for i1:=1 to 2 do

for i2:=1 to 2 do

for i3:=1 to 2 do

if ord(i1=1)+ord(i1=1)+ord((i3=2) and (i2=2))=2 then begin

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

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

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

writeln;

end;

end.

原理:列舉每個人吃或沒吃的情況,1是吃了,b是沒吃,之後,因為ord(true)=1 ord(false)=0,判斷出說真話的有兩人,之後輸出即可。

樓主!手打的!!!!!

2樓:匿名使用者

vari1,i2,i3,j:longint;

begin

for i1:=1 to 2 do

for i2:=1 to 2 do

for i3:=1 to 2 do

if ord(i1=1)+ord(i1=1)+ord((i3=2) and (i2=2))=2 then begin

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

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

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

writeln;

end;

end.

pascal程式語言中宣告record型別中的case用法,多謝

type birthorage birthflag,ageflag persontype record id string 18 name string 50 gender male,female case flag birthorage of birthflag birthday longint ...

Pascal程式設計問題(送分題)

vara,b integer a 字母數,b 數字數 c char begin a 0 b 0 while c do begin read c if c 0 and i 9 then b b 1 if i a and i z then a a 1 if i a and i z then a a 1 ...

求會pascal語言的幫我編道題

varn string s,i integer begin readln n readln s while s 0 do begin i 1 while i1 and n 1 0 do delete n,1,1 writeln n end.varn string s,i integer begin ...