求PASCAL程序

来源:百度知道 编辑:UC知道 时间:2024/05/12 18:01:06
编程模拟剪刀、石头、布游戏:用S表示剪刀,用R表示石头,用P表示布。规则是,:剪刀剪布,石头砸剪刀,布包石头。游戏者分别把自己的选择输入计算机给出结果。

var
c1,c2,c3:char;
begin
read(c1,c3,c2);
if c1=c2 then write('Equ')
else if (c1='S') and (c2='R') or (c1='R') and (c2='P') or (c1='P') and (c2='S')
then write('Fall')
else write('Win')
end.

用if语句做吧 游戏者有没有规定几位?

两位游戏人的程序:
program stjzb;
var
f,s:char;
begin
writeln('Input the first choice(s,r,p):');
readln(f);
writeln('Input the second choice(s,r,p):');
readln(s);
case f of
's':begin if s='r' then write('The second one is the winner.')
else if s='p' then write('The first one is the winner.') else write('Tied!!')
end;
'r':begin if s='s' then write('The first one is the winner.')
else if s='p' then write('The second one is the winner.') else write('Tied!!'