Hi guys this is a small program abt Tower of Hanoi...(if u don't wat the prblem is plz mail me I'll give the explanation for tower of Hanoi)
But my real worry is when the same logic is tried in 'C' the program works fine for recursion...
But when it is implemented in java..O/p is terribly out of place..Can u plz suggest ways to achieve the result???
I am including the code here...
TIA
ravi
class TowerOfHanoi
{
void tower(int n, char a, char b, char c)
{
// this is a recursive function which calls itself
if (n>0)
{
tower(n-1,'a','c','b');
System.out.println("Move disk "+n+" from "+ a +" to "+ b +" via "+c);
tower(n-1,'c','b','a');
}
}
public static void main(
String args[])
{
tower(3,'a','b','c');
}
}