我要编写一个Pascal程序,if语句:和电脑猜拳。那位大侠帮我一下?跪求------------

来源:百度知道 编辑:UC知道 时间:2024/06/16 15:27:53
我要编写一个Pascal程序,if语句:和电脑猜拳。那位大侠帮我一下?跪求------------

用随机吧
program ddd;
var computer,player;
begin
randomize;
repeat
computer:=trunc(random(3)+0.5);
read(player);
until player<>computer;
if (computer-player) mod 3=1 then writeln('Computer win') else
writeln('Player win');
end.
1->拳头,2->布,3->剪刀

program caiquan;
var a:string;
b:integer;
i:longint;
k,n:longint;
begin
repeat
readln(a);
b:=random(2);
if b=0 then
begin
if a='jiandao' then inc(k);
if a='shitou' then inc(i);
if a='bu' then inc(n);
end;
if b=1 then
begin
if a='jiandao' then inc(i);
if a='shitou' then inc(n);
if a='bu' then inc(k);
end;
if b=2 then
begin
if a='jiandao' then inc(n);
if a='shitou' then inc(k);
if a='bu' then inc(i);
end;
until (k=3) or (