アットウィキロゴ

311 pav

class pro0311 extends Thread{
int px,py;
int score;
int m,n;
int[][] x=new int[6][6];

pro0311(){
for (m=1;m<6;m++){
for (n=1;n<6;n++){
x[m][n]=0;
}
}
px=1;
py=1;
}

public void run() {
int t;
double sai;
t=0;
while(t<101){
sai=Math.random();
if (sai>0.5)px=px+1;
if (sai<0.5)px=px-1;
if (px<1)px=1;
if (px>5)px=5;
sai=Math.random();
if (sai>0.5)py=py+1;
if (sai<0.5)py=py-1;
if (py<1)py=1;
if (py>5)py=5;
x[px][py]=1;
score=0;
for (m=1;m<6;m++){
for (n=1;n<6;n++){
score=score+x[m][n];
}
}
t=t+1;
System.out.println(score);
try {sleep(100);} catch (InterruptedException e) {System.out.println("fail");}
}

}

public static void main(String[] args){
 pro0311 th = new pro0311(); 
 th.start(); 
}

}
最終更新:2010年09月19日 02:54