herrDeng網內搜尋
自訂搜尋
Ads
訂閱:
張貼留言 (Atom)
熱門文章
-
計算你的BMI
-
GCD(10^10+1, 10^11+2)=?
-
輸出你的課表 含Java code以及結果
-
1. 利用遞迴input n算2^n 2. 用C算GCD(3333,456)
-
請用 C/C++/java寫一簡易程式
-
一、 試利用switch case由程式中直接輸入一個1~7 之間的整數day,代表星期一到星期日。若day 的值是1,則印出 "星期一",若day 的值是2,則印出 "星期二",若day 的值是7,則印出 "星期日",...
-
BMI (Body Mass Index)= 體重 (kg) / 身高 ^2(m 2 ) 在台灣,行政院衛生署乃根據其相關研究,於2002年4月公佈台灣成人肥胖標準: BMI<18.5 為過輕, 18.5≦BMI<24 為正常體重, 24≦BMI<27 為過重, BM...
-
33, 45, 87, 99, 27 算平均
61 則留言:
public class ex1 {
static int N=0;
static void hanoi(char A,char B,char C,int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C,n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',5);
}
}
package hello;
public class ex01 {
static int N=0;
static void hanoi(char A,char B,char C,int n){
if(n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,B,C,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(A,B,C,n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',5);
}
}
public class ex01 {
static int N=0;
static void hanoi (char A, char B, char C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,C,B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C, n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C', 5);
}
}
package hello;
public class ex01 {
static int N=0;
static void hanoi(char A,char B,char C,int n){
if(n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,B,C,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(A,B,C,n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',5);
}
}
public class ex1 {
static int N=0;
static void hanoi(char A,char B,char C,int n){
if(n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C,n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',5);
}
}
package hello;
public class ex01 {
static int N=0;
static void hanoi(char A,char B,char C,int n){
if(n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,B,C,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(A,B,C,n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',5);
}
}
public class hello {
static int N=0;
static void hanoi (char A, char B, char C , int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A, C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B, A, C, n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C', 4);
}
}
package p1;
public class hw1 {
static int N=0;
static void hanoi(char A,char B,char C,int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(A,C,B,n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',5);
}
}
package p1;
public class hw1 {
static int N=0;
static void hanoi(char A, char B, char C, int n){
if(n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C,n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',5);
}
}
public class hello {
static int N=0;
static void hanoi (char A, char B, char C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(A,C,B,n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',5);
}
}
public class ex01
{
static int N=0;
static void hanoi(int A,int B,int C,int n)
{
if (n==1)
System.out.println("移動"+n+":"+A+"=>"+C);
else
{
hanoi(A,C,B,n-1);
System.out.println("移動"+n+":"+A+"=>"+C);
hanoi(B,A,C,n-1);
}
}
public static void main(String[] args)
{
hanoi(1,2,3,4);
}
}
public class hello {
static int N=0;
static void hanoi (char A, char B, char C , int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A, C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B, A, C, n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C', 4);
}
}
public class ex12 {
static int N=0;
static void hanoi(char A, char B, char C, int n){
if(n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C,n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',4);
}
}
public class a01 {
static int N=0;
static void Hn(char A,char B,char C,int n){
if(n==1)System.out.println("第"+(++N)+"步:\t"+n+"從"+A+"->"+C);
else{
Hn(A,C,B,n-1);
System.out.println("第"+(++N)+"步:\t"+n+"從"+A+"->"+C);
Hn(B,A,C,n-1);
}
}
public static void main(String[] args) {
Hn('A','B','C',4);
}
}
第1步: 1從A->B
第2步: 2從A->C
第3步: 1從B->C
第4步: 3從A->B
第5步: 1從C->A
第6步: 2從C->B
第7步: 1從A->B
第8步: 4從A->C
第9步: 1從B->C
第10步: 2從B->A
第11步: 1從C->A
第12步: 3從B->C
第13步: 1從A->B
第14步: 2從A->C
第15步: 1從B->C
public class hello {
static int N=0;
static void hanoi(char A, char B, char C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A, C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B, A, C, n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C', 5);
}
}
package p1;
public class ex01 {
static int N=0;
static void hanoi(char A, char B, char C, int n){
if (n==1)
System.out.println((++N)+":移動" +n +":" +A+"=>"+C);
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動" +n +":" +A+"=>"+C);
hanoi(B,A,C, n-1);
}
}
public static void main(String[] args)
{
hanoi('A','B','C', 5);
}
}
public class hello {
static int N=0;
static void hanoi (char A, char B, char C , int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A, C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B, A, C, n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C', 4);
}
}
public class Ex12 {
static int N=0;
static void hanoi(char A, char B, char C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A, C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B, A, C, n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',5);
}
}
public class hello {
static int N=0;
static void hanoi (char A, char B, char C , int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A, C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B, A, C, n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C', 4);
}
}
package ererer;
public class ex1 {
static int N=0;
public static void hanoi(int A,int B,int C ,int n) {
if(n==1)
System.out.println((++N)+":移動"+N+":"+A+"=>"+C);
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C,n-1);
}
}
public static void main(String[] args) {
hanoi(1,2,3,4);
}
}
public class hello {
static int N=0;
static void hanoi (char A, char B, char C , int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A, C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B, A, C, n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C', 4);
}
}
package ererer;
public class ex1 {
static int N=0;
public static void hanoi(int A,int B,int C ,int n) {
if(n==1)
System.out.println((++N)+":移動"+N+":"+A+"=>"+C);
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C,n-1);
}
}
public static void main(String[] args) {
hanoi(1,2,3,4);
}
}
package ererer;
public class ex1 {
static int N=0;
public static void hanoi(int A,int B,int C ,int n) {
if(n==1)
System.out.println((++N)+":移動"+N+":"+A+"=>"+C);
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C,n-1);
}
}
public static void main(String[] args) {
hanoi(1,2,3,4);
}
}
package hello;
public class hello {
static int N=0;
static void hanoi(char A, char B, char C,int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,B,C, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C, n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C', 5);
}
}
package ddt;
public class ttd {
static int N=0;
public static void hanoi(int A,int B,int C,int n)
{
if(n==1)
System.out.println((++N)+":移動"+N+":"+A+"=>"+C);
else
{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動"+N+":"+A+"=>"+C);
hanoi(B,C,A,n-1);
}
}
public static void main(String[] args) {
hanoi(1,2,3,4);
}
}
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hw1;
public class hello {
static int N=0;
static void hanoi(char A, char B, char C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A, C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B, A, C, n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C', 5);
}
}
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
public class EX01 {
static int N=0;
static void hanoi(char A,char B,char C,int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C,n-1);
}
}
public static void main(String[]args){
hanoi('A','B','C',5);
}
}
public class ex {
static int N=0;
static void hanoi(int A, int B, int C, int n){
if (n==1)
System.out.println((++N)+"移動"+n+": "+A+"=>"+C);
else {
hanoi (A,C,B,n-1);
System.out.println((++N)+"移動"+n+": "+A+"=>"+C);
hanoi(B,A,C,n-1);
}
}
public static void main(String[] args) {
hanoi(1,2,3, 1000);
}
}
public class ex01 {
static int N=0;
public static void hanoi(int A, int B,int C,int n) {
if (n==1)
System.out.println((++N)+"步 "+"移動"+n+"層"+":"+A+"柱=>"+C+"柱");
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+"步 "+"移動"+n+"層"+":"+A+"柱=>"+C+"柱");
hanoi(B,A,C,n-1);
}
}
public static void main(String[] args){
hanoi(1,2,3,4);
}
}
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
public class Ex12 {
static int N=0;
static void hanoi(char A, char B, char C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A, C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B, A, C, n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',5);
}
}
public class ex1 {
static int N=0;
static void hanoi(char A,char B,char C,int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C,n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',5);
}
}
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
public class ex1 {
static int N=0;
static void hanoi(char A,char B,char C,int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,C,B,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C,n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',5);
}
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
2016年12月26日 下午12:10
匿名 B10233049 黃家崙 提到...
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
2016年12月26日 下午12:10
匿名 B10233049 黃家崙 提到...
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
public class ex01 {
static int N=0;
static void hanoi (char A, char B, char C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,C,B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C, n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C', 5);
}
}
public class ex01 {
static int N=0;
static void hanoi (char A, char B, char C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,C,B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B,A,C, n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C', 5);
}
}
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class ex01 {
static int N=0;
static void hanoi(char A,char B,char C,int n){
if(n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else{
hanoi(A,B,C,n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(A,B,C,n-1);
}
}
public static void main(String[] args) {
hanoi('A','B','C',5);
}
}
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------------------------------------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
package hello;
public class hello{
static int N=0;
static void hanoi(int A,int B, int C, int n){
if (n==1)
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
else
{
hanoi(A , C, B, n-1);
System.out.println((++N)+":移動"+n+":"+A+"=>"+C);
hanoi(B , A, C, n-1);
}
}
public static void main (String[] args){
hanoi (1,2,3, 4);
}
}
------
1:移動1:1=>2
2:移動2:1=>3
3:移動1:2=>3
4:移動3:1=>2
5:移動1:3=>1
6:移動2:3=>2
7:移動1:1=>2
8:移動4:1=>3
9:移動1:2=>3
10:移動2:2=>1
11:移動1:3=>1
12:移動3:2=>3
13:移動1:1=>2
14:移動2:1=>3
15:移動1:2=>3
張貼留言