class game0222{
public static void main(String [] args) {
int x,dx,xmode;
int y,dy,ymode;
int mode;
int coin;
int h;
int t;
mode=0;
x=60;
xmode=0;
y=40;
ymode=0;
t=0;
while(t<100){
coin=seekcoin();
dx=0;
if(xmode>0)xmode=xmode+1;
if(xmode==4)xmode=0;
h=0;
if (coin==2)h=h+1;
if (xmode==0)h=h+1;
if(h==2)dx=1;
h=0;
if (coin==3)h=h+1;
if (xmode==0)h=h+1;
if(h==2)dx=-1;
x=x+dx;
h=0;
if (coin==4)h=h+1;
if (xmode==0)h=h+1;
if(h==2)xmode=1;
coin=seekcoin();
dy=0;
if(ymode>0)ymode=ymode+1;
if(ymode==4)ymode=0;
h=0;
if (coin==2)h=h+1;
if (ymode==0)h=h+1;
if(h==2)dy=1;
h=0;
if (coin==3)h=h+1;
if (ymode==0)h=h+1;
if(h==2)dy=-1;
y=y+dy;
h=0;
if (coin==4)h=h+1;
if (ymode==0)h=h+1;
if(h==2)ymode=1;
h=0;
if(xmode==2)h=h+1;
if(ymode==2)h=0;
if(x-y<20)h=h+1;
if(h==2)mode=1;
h=0;
if(ymode==2)h=h+1;
if(xmode==2)h=0;
if(x-y<20)h=h+1;
if(h==2)mode=2;
if(mode==1)t=1000;
if(mode==2)t=1000;
t=t+1;
}
if(mode==1)System.out.println("xの勝利です");
if(mode==2)System.out.println("yの勝利です");
}
public static int seekcoin(){
double p;
int c;
p=Math.random();
c=1;
if(p>0.25)c=2;
if(p>0.5)c=3;
if(p>0.75)c=4;
return c;
}
}
最終更新:2011年02月16日 05:54