pascal风暴

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

program zhjh;
var
st,tt:char;
begin
readln(st);
readln(tt);
if (tt='S')and(st='R') then writeln('乙赢');
if (tt='S')and(st='P') then writeln('甲赢');
if (tt='S')and(st='S') then writeln('平');
if (tt='R')and(st='P') then writeln('乙赢');
if (tt='R')and(st='R') then writeln('平');
if (tt='P')and(st='P') then writeln('平');
end.

var
st,tt:char;
s,t,m,n:integer;
function srp:integer;
begin
if (t=s) then begin srp:=3; exit; end;
if ((s=1) and (t=3)) then begin srp:=1; exit; end;
if ((t=1) and (s=3)) then begin srp:=2; exit; end;
if (s>t) then begin srp:=1; exit; end;
else begin srp:=2; exit; end;
end;
begin
readln(st);
readln(tt);
case st of
's':s:=3;
'r':s:=