啊~~~`
那該死的tic-tac-toe......
怎會這麼難搞的說.......
以下是我做的....XDDDD
program tiatac01;
uses crt;
label return;
var
a,b,c,d,e,f,g,h,i,input,symbol,YN:char;
j,comp:integer;
name1,name2:string;
win:boolean;
procedure reset;
begin
a:='A';
b:='B';
c:='C';
d:='D';
e:='E';
f:='F';
g:='G';
h:='H';
i:='I';
win:=false;
end;
procedure inputpos;
begin
textcolor(10);
if j mod 2=1
then begin
symbol:='X';
write(name1,', please input the position:');
end
else begin
symbol:='O';
write(name2,', please input the position:');
end;
readln(input);
case input of
'A','a':a:=symbol;
'B','b':b:=symbol;
'C','c':c:=symbol;
'D','d':d:=symbol;
'E','e':e:=symbol;
'F','f':f:=symbol;
'G','g':g:=symbol;
'H','h':h:=symbol;
'I','i':i:=symbol;
end;
end;
procedure board;
begin
textcolor(12);
writeln;
writeln('| | | |');
writeln('| ',a,' | ',b,' | ',c,' |');
writeln('|___|___|___|');
writeln('| | | |');
writeln('| ',d,' | ',e,' | ',f,' |');
writeln('|___|___|___|');
writeln('| | | |');
writeln('| ',g,' | ',h,' | ',i,' |');
writeln('| | | |');
writeln;
end;
procedure checkwin;
begin
if ((a=b) and (b=c)) or
((d=e) and (e=f)) or
((g=h) and (h=i)) or
((a=d) and (d=g)) or
((b=e) and (e=h)) or
((c=f) and (f=i)) or
((a=e) and (e=i)) or
((c=e) and (e=g)) then
win:=true;
end;
procedure comps;
begin
comp:=random(9);
end;
begin
repeat;
clrscr;
reset;
textcolor(10);
write('Please input the name of player1 : ');
readln(name1);
write('Please input the name of player2 : ');
readln(name2);
board;
for j:=1 to 9 do
if not win then
begin
board;
inputpos;
inputa;
checkwin;
end;
textcolor(10);
if win then
if symbol = 'X' then
writeln(name1,' win the game!')
else writeln(name2,' win the game!')
else writeln('Draw game!');
writeln('Play again(Y for Yes , No for No)?');
readln(YN);
until YN = 'N';
end.
囧~~~~~~~~~~~
說實已經做到差不多.......
還差什麼選完不可再選的樣子.....
哈哈.....
在學校根本就做不了(汗)
回到家....
還真的是單選呀!(擦汗)只有單一個player可以選.....囧
還有不知道是誰寫了什麼“player with computer”.....
該死的!我哪會做.....
找懂的“人”或“物”教教我吧~~~~~~(合掌)