JAVA程式設計學習
2009年6月15日 星期一
Lab 29 : Hanoi Tower
The pseudocode for Hanoi Tower is as follows:
solve(N, Src, Aux, Dst)
if N is 0 return
solve(N-1, Src, Dst, Aux)
Move N from Src to Dst
solve(N-1, Aux, Src, Dst)
Write the Java program based on the pseudocode in the above.
Lab 28 : Factorial
Write a Java program that computes N! where N is a positive integer.
Hint:
public static long factorial(int n)
Lab 27 : Recursive method
Write a recursive method to compute Fibonacci series.
Hint:
1.
fib(n)=fib(n-1)+fib(n-2)
2.
public static long fib(int n)
2009年6月1日 星期一
Lab 26 : Modular Sorting
Write a sort method which takes a double array as parameter
and returns the sorted array. Call this method in a main program.
Hint: The lab is a rewriting of
Lab Sorting
to make the sorting procedure a reusable method।
main Class:
Array Class:
Lab 25 : Array
Study Display 6।1, and then write a program that can sort numbers in ascending order.
‹
›
首頁
查看網路版