點樣張依個progame改頭換面!大量分(下)

2008-12-05 7:47 am
for(j=0;j<=5;j++)
if(a[j] ==y && b[j] ==y && c[j] ==y && d[j] ==y)
win++;
else if(b[j] ==y && c[j] ==y && d[j] ==y && e[j] ==y)
win++;
else if(c[j] ==y && d[j] ==y && e[j] ==y && f[j] ==y)
win++;


for(j=0;j<=3;j++)
if(a[j] ==y && b[j+1] ==y && c[j+2] ==y && d[j+3] ==y)
win++;
else if (b[j] ==y && c[j+1] ==y && d[j+2] ==y && e[j+3] ==y)
win++;
else if (c[j] ==y && d[j+1] ==y && e[j+2] ==y && f[j+3] ==y)
win++;

if (win!=1){
if(play%2==0){do{
Scanner sc = new Scanner(System.in);
System.out.print("Player 1 type a column (0-6) or 9 to quit current game : ");
k = sc.nextInt();
if (k<0 || k>6)
System.out.println("Range of column should be 0 to 6!");
if (f[k]!=0)
System.out.println("Column " + k + " is full!");
}while(k <0 || k>6 || f[k]!=0);
y=1;}

else{do{
Scanner sc = new Scanner(System.in);
System.out.print("Player 2 type a column (0-6) or 9 to quit current game : ");
k = sc.nextInt();
if (k<0 || k>6)
System.out.println("Range of column should be 0 to 6!");
if (f[k]!=0)
System.out.println("Column " + k + " is full!");
}while(k<0 || k >6 || f[k]!=0);
y=2;}


if(a[k] == 0)
a[k] = y;
else if (b[k] == 0)
b[k] = y;
else if (c[k] == 0)
c[k] = y;
else if (d[k] == 0)
d[k] = y;
else if (e[k] == 0)
e[k] = y;
else if (f[k] == 0)
f[k] = y;



play++;}
}while(win != 1);

System.out.println("Player"+y+" win this game!");
if(y==2)
player2++;
else
player1++;
Scanner sc = new Scanner(System.in);
System.out.print("Do you want to continue (Yes=1, No=0)?");
k = sc.nextInt();
}while(k ==1);
System.out.println("Player1 wins " +player1 +" game.");
System.out.println("Player2 wins " +player2 +" game.");
if (player1==player2)
System.out.println("No final winner.");
else if(player2>player1)
System.out.println("The final winner is player2.");
else
System.out.println("The final winner is player1.");
System.out.println("Bye Bye!");

}
}

回答 (1)

2008-12-05 7:53 am
✔ 最佳答案
我都同意
要自己做架呢d野
問左人自己又唔識
阿sir 問番你你唔識問咪死


收錄日期: 2021-04-24 23:32:37
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20081204000051KK02094

檢視 Wayback Machine 備份