歡迎光臨飯的戰鬥日記∼

a
zafara
暱稱: 饅頭
性別: 男
國家: 香港
MORE... 

« March 2015 »
SMTWTFS
1234567
891011121314
15161718192021
22232425262728
293031

最新出爐
2013-01-19
2012-12-30
2012-12-28
2012-12-07
2012-12-05

飯團分類
全部 (446)
L.H.S.通告 (11)
未分類 (435)

竟見接受思想照舊箱
最近三個月尚無任何留言

誰來買飯團了?
最近沒有訪客

每月推介


顧客黑名單

暫時放著沒用

Adopt one today!Adopt one today!Adopt one today! 


出爐統計
文章總數: 446
留言總數: 448
今日人氣: 232
累積人氣: 40388

站內搜尋

RSS Feed

2007 年 4 月 17 日  星期二


該死的Tic-tac-toc! 飯團分類: 未分類

啊~~~`

那該死的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”.....

該死的!我哪會做.....

找懂的“人”或“物”教教我吧~~~~~~(合掌)

 






訪客留言 (返回 zafara 的日誌)

訪客名稱:
電郵地址: (不會公開)
驗證碼:  按此更新驗證碼 (如看不清楚驗證碼請點擊圖片刷新)
俏俏話: (必需 登入 後才能使用此功能)
[ 開啟多功能編輯器 ]