用Pascal编程

2024-11-22 07:44:03
推荐回答(2个)
回答1:

program SRP_GAME;
const
s1='Player one win!';
s2='Player two win!';
s3='No winner.';
var
p1,p2:integer;

procedure init(var x:integer);
var
t:char;
begin
readln(t);
case t of
'S': x:=1;
'R': x:=2;
'P': x:=3;
end;
end;

begin
write('Player one: ');
init(p1);
write('Player two: ');
init(p2);

case p1-p2 of
-2: writeln(s1);
-1: writeln(s2);
0: writeln(s3);
1: writeln(s1);
2: writeln(s2);
end;
end.
(每一行前面的空格都不见了......)
可以加一个循环实现重复玩,键入“X”结束。

回答2:

http://www.immortalleyuan.com/bbs/?u=252