星期二, 1月 15, 2008
星期五, 1月 11, 2008
Lab 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.
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 Factorial
Write a Java program that computes N! where N is a positive integer.
Hint:
public static long factorial(int n)
Hint:
public static long factorial(int n)
lab recursive method
Write a recursive method to compute Fibonacci series.
Hint:
fib(n)=fib(n-1)+fib(n-2)
Hint:
fib(n)=fib(n-1)+fib(n-2)
星期二, 1月 08, 2008
星期五, 1月 04, 2008
Bonus: 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.
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.
星期四, 1月 03, 2008
網路安全
學校的公用電腦有可能被植入木馬程式,因此你的帳號密碼可能已經被木馬程式紀錄並且流出,這些駭客集團會到各網站逐一測試你所流出的帳號密碼,如果你常使用的網站用的是同ㄧ組帳號密碼,那麼你在其他網站的個人資料也可能被入侵流出。
最近不少知名網站被駭客入侵,個人資料外洩日益頻繁。因此建議你儘速找一台沒有被植入木馬程式的電腦,更改你重要網站的密碼。
星期三, 1月 02, 2008
Lab Magic Parking Tower
A parking tower is out of order someday. If you park a Benz, you will end up with a Torben. Write a program to simulate this scenario. First create a class called CarParked which has a static method called outOfOrder. Name an object called yourCar, which happens to be a Benz. Your program should contain a class called CarParked and a test program called CarParkedDemo which test the method by CarParked.outOfOrder(yourCar).
Hint: You may study Display 5.14 to get some ideas.
Hint: You may study Display 5.14 to get some ideas.