I am that guy. Here is the code I wrote:
#include <iostream>
#include <ctime>
using namespace std;
int moves=0;
void hanoi(int disks, int start, int end, int hold)
{
if (disks==0) return;
hanoi(disks-1, start, hold, end);
// cout << ++moves << ": Move disk " << disks << " from pole " << start << " to " << end << endl;
hanoi(disks-1, hold, start, end);
}
int main( )
{
long time1 = time( 0 );
hanoi(30,1,3,2);
long time2 = time( 0 );
cout << endl << time2-time1 << endl;
return 0;
}
If he didn't cheat and java is quicker I'm quite impressed. But we all know java's shortcomings are in the speed of its GUI etc.
I think the speed difference we noted was due to MSVC++ 6 being, what, 2 or 3 years old now. No doubt the Java compiler has better optimisations in it being so much more up to date.
- seb