horsemanship世界

星期一, 6月 12, 2006

Lab16

public class recursive {
public static void main(String[] args)
{
recursive(3,1,2,3);
}
public static void recursive (int i,int one,int two,int three ){
if(i==1) {
System.out.println("Move dis"+1+" From "+one+" to "+three);
}
else{
recursive ( i-1, one, three, two );
System.out.println("Move dis"+i+" From "+one+" to "+three);
recursive ( i-1, two, one, three );
}}}
結果:

0 Comments:

張貼留言

<< Home