📄 ttt.java
字号:
}
if (gotone==1) {
found = true;
boxes[bp]=2;
}
}
public void goforblock () {
int p,three,ffirst,bp,gotone;
ffirst=1;
bp=0;
gotone=0;
three=0;
for (p=0;p<3;p=p+1) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=0;p<3;p=p+1) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=3;p<6;p=p+1) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=3;p<6;p=p+1) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=6;p<9;p=p+1) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=6;p<9;p=p+1) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=0;p<7;p=p+3) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=0;p<7;p=p+3) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=1;p<8;p=p+3) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=1;p<8;p=p+3) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=2;p<9;p=p+3) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=2;p<9;p=p+3) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=0;p<9;p=p+4) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=0;p<9;p=p+4) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=2;p<7;p=p+2) if (boxes [p]==ffirst) three=three+1;
if (three==3) for (p=2;p<7;p=p+2) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=9;p<12;p=p+1) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=9;p<12;p=p+1) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=12;p<15;p=p+1) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=12;p<15;p=p+1) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=15;p<18;p=p+1) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=15;p<18;p=p+1) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=9;p<16;p=p+3) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=9;p<16;p=p+3) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=10;p<17;p=p+3) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=10;p<17;p=p+3) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=11;p<18;p=p+3) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=11;p<18;p=p+3) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=9;p<18;p=p+4) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=9;p<18;p=p+4) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=11;p<16;p=p+2) if (boxes [p]==ffirst) three=three+1;
if (three==3) for (p=11;p<16;p=p+2) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
three=0;
for (p=18;p<21;p=p+1) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=18;p<21;p=p+1) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=21;p<24;p=p+1) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=21;p<24;p=p+1) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=24;p<27;p=p+1) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=24;p<27;p=p+1) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=18;p<25;p=p+3) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=18;p<25;p=p+3) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=19;p<26;p=p+3) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=19;p<26;p=p+3) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=20;p<27;p=p+3) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=20;p<27;p=p+3) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=18;p<27;p=p+4) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=18;p<27;p=p+4) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
for (p=20;p<25;p=p+2) if (boxes [p]==ffirst) three=three+1;
if (three==2) for (p=20;p<25;p=p+2) if (boxes [p]==0) {
bp=p;
gotone=1;
}
three=0;
if (gotone==1) {
found = true;
boxes[bp]=2;
}
}
public void putrandom () {
int a,b;
while (found==false) {
a=(int) (26 * Math.random());
if (boxes[a]==0) {
found=true;
boxes[a]=2;
} //if
checkfull ();
if (full==true) found=true;
} // while
} // putrand
void checkwin ()
{
winner1=0;
winner2=0;
int p,three;
three=0;
for (p=0;p<3;p=p+1) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=3;p<6;p=p+1) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=6;p<9;p=p+1) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=0;p<7;p=p+3) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=1;p<8;p=p+3) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=2;p<9;p=p+3) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=0;p<9;p=p+4) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=2;p<7;p=p+2) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=0;p<3;p=p+1) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=3;p<6;p=p+1) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=6;p<9;p=p+1) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=0;p<7;p=p+3) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=1;p<8;p=p+3) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=2;p<9;p=p+3) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=0;p<9;p=p+4) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=2;p<7;p=p+2) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=9;p<12;p=p+1) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=12;p<15;p=p+1) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=15;p<18;p=p+1) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=9;p<16;p=p+3) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=10;p<17;p=p+3) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=11;p<18;p=p+3) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=9;p<18;p=p+4) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=11;p<16;p=p+2) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=9;p<12;p=p+1) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=12;p<15;p=p+1) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=15;p<18;p=p+1) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=9;p<16;p=p+3) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=10;p<17;p=p+3) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=11;p<18;p=p+3) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=9;p<18;p=p+4) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=11;p<16;p=p+2) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=18;p<21;p=p+1) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=21;p<24;p=p+1) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=24;p<27;p=p+1) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=18;p<25;p=p+3) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=19;p<26;p=p+3) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=20;p<27;p=p+3) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=18;p<27;p=p+4) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=20;p<25;p=p+2) if (boxes [p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=18;p<21;p=p+1) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=21;p<24;p=p+1) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=24;p<27;p=p+1) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=18;p<25;p=p+3) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=19;p<26;p=p+3) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=20;p<27;p=p+3) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=18;p<27;p=p+4) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=20;p<25;p=p+2) if (boxes [p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=0;p<19;p=p+9) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=1;p<20;p=p+9) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=2;p<21;p=p+9) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=3;p<22;p=p+9) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=4;p<23;p=p+9) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=5;p<24;p=p+9) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=6;p<25;p=p+9) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=7;p<26;p=p+9) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=8;p<27;p=p+9) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=0;p<25;p=p+12) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=1;p<26;p=p+12) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=2;p<27;p=p+12) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=6;p<19;p=p+6) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=7;p<20;p=p+6) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=8;p<21;p=p+6) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=0;p<21;p=p+10) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=3;p<24;p=p+10) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=6;p<27;p=p+10) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=2;p<19;p=p+8) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=5;p<22;p=p+8) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=8;p<25;p=p+8) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=0;p<27;p=p+13) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=2;p<25;p=p+11) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=6;p<21;p=p+7) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=8;p<19;p=p+5) if (boxes[p]==1) three=three+1;
if (three==3) winner1=winner1+1;
three=0;
for (p=0;p<19;p=p+9) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=1;p<20;p=p+9) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=2;p<21;p=p+9) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=3;p<22;p=p+9) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=4;p<23;p=p+9) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=5;p<24;p=p+9) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=6;p<25;p=p+9) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=7;p<26;p=p+9) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=8;p<27;p=p+9) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=0;p<25;p=p+12) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=1;p<26;p=p+12) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=2;p<27;p=p+12) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=6;p<19;p=p+6) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=7;p<20;p=p+6) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=8;p<21;p=p+6) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=0;p<21;p=p+10) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=3;p<24;p=p+10) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=6;p<27;p=p+10) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=2;p<19;p=p+8) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=5;p<22;p=p+8) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=8;p<25;p=p+8) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=0;p<27;p=p+13) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=2;p<25;p=p+11) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=6;p<21;p=p+7) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
for (p=8;p<19;p=p+5) if (boxes[p]==2) three=three+1;
if (three==3) winner2=winner2+1;
three=0;
xwins="No of wins for X: "+winner1;
ywins="No of wins for O: "+winner2;
}
} // class TTT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -