class game0
323{
int s;
int bx,by;
int px[]=
new int[11];
int py[]=new int[11];
int pxs[]=new int[11];
int pys[]=new int[11];
public static void main(String [] args) {
game0323 test=new game0323();
}
for (s=1;s<11;s++){
px[1]=s;
py[1]=s;
}
for(s=1;s<11;s++){
System.out.println(planx(s,bx,by,px,py));
System.out.println(plany(s,bx,by,px,py));
}
}
public int planx(int s,int bx,int by,int[] px,int[] py){
int pl,don;
pl=plan(s,bx,by,px,py);
don=px[s];
if (pl==3)don=px[s]+1;
if (pl==4)don=px[s]-1;
return don;
}
public int plany(int s,int bx,int by,int[] px,int[] py){
int pl,don;
pl=plan(s,bx,by,px,py);
don=py[s];
if (pl==1)don=py[s]+1;
if (pl==2)don=py[s]-1;
return don;
}
public int plan(int s,int bx,int by,int[] px,int[] py){
int e0,e1,e2,e3,e4;
int p;
e0=met(px[s],py[s],bx,by);
e1=met(px[s],py[s]+1,bx,by);
e2=met(px[s],py[s]-1,bx,by);
e3=met(px[s]+1,py[s],bx,by);
e4=met(px[s]-1,py[s],bx,by);
p=0;
if(e1<e0)p=1;
if(e1<e0)e0=e1;
if(e2<e0)p=2;
if(e2<e0)e0=e2;
if(e3<e0)p=3;
if(e3<e0)e0=e3;
if(e4<e0)p=4;
if(e4<e0)e0=e4;
return p;
}
public int met(int x1,int y1,int x2,int y2){
int e;
e=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
return e;
}
}
最終更新:2011年02月20日 04:59