t246uy3n1998
Thành viên
- Tham gia
- 17/12/2012
- Bài viết
- 10
Đây là game oẳn tù tì mình làm bằng pascal.
Download:Xem file đính kèm #oantuti.zip
Code:
Download:Xem file đính kèm #oantuti.zip
Code:
program oantuti;
uses crt;
var N:integer;
h1, h2, h3, h4:integer;
begin
clrscr;
writeln('Hello! Choose your option.');
writeln('1: one player.');
writeln('2: two players.');
writeln('What is your option? ');
readln(N);
if N=1 then
begin
clrscr;
randomize;
writeln('Which do you choose?');
writeln('1: rock');
writeln('2: paper');
writeln('3: scissors');
writeln('What is your option?');
readln(h1);
h2:=random(2)+1;
clrscr;
writeln('1: rock');
writeln('2: paper');
writeln('3: scissors');
writeln('');
writeln('You chose ',h1);
writeln('Computer chose ',h2);
writeln('');
if (h1=1) and (h2=1) or (h1=2) and (h2=2) or (h1=3) and (h2=3) then
writeln('Draw!');
if (h1=2) and (h2=1) or (h1=3) and (h2=2) or (h1=1) and (h2=3) then
writeln('You win!');
if (h1=1) and (h2=2) or (h1=2) and (h2=3) or (h1=3) and (h2=1) then
writeln('You lose!');
readln;
end;
if N=2 then
begin
clrscr;
writeln('Which does player 1 choose?');
writeln('Be sure you opponent are not watching you.');
writeln('1: rock');
writeln('2: paper');
writeln('3: scissors');
writeln('What is your option?');
readln(h3);
clrscr;
writeln('Which does player 2 choose?');
writeln('Be sure you opponent are not watching you.');
writeln('1: rock');
writeln('2: paper');
writeln('3: scissors');
writeln('What is your option?');
readln(h4);
clrscr;
writeln('1: rock');
writeln('2: paper');
writeln('3: scissors');
writeln('');
writeln('Player 1 chose ',h3);
writeln('Player 2 chose ',h4);
writeln('');
if (h3=1) and (h4=1) or (h3=2) and (h4=2) or (h3=3) and (h4=3) then
writeln('Draw!');
if (h3=2) and (h4=1) or (h3=3) and (h4=2) or (h3=1) and (h4=3) then
writeln('Player 1 win!');
if (h3=1) and (h4=2) or (h3=2) and (h4=3) or (h3=3) and (h4=1) then
writeln('Player 2 win!');
readln;
end;
end.