void move(int count,int start,int finish,int temp){
static int i = 1;
if(count > 0){
move(count-1,start,temp,finish);
cout << "step " << i++ << " : ";
cout << "move disk " << count << " form"
<< start << " to " << finish << ".\n";
move(count-1,temp,finish,start);
}
}
int main(){
move(3,1,3,2);
return 0;
}
static int i = 1;
if(count > 0){
move(count-1,start,temp,finish);
cout << "step " << i++ << " : ";
cout << "move disk " << count << " form"
<< start << " to " << finish << ".\n";
move(count-1,temp,finish,start);
}
}
int main(){
move(3,1,3,2);
return 0;
}
[此贴子已经被作者于2007-7-3 8:52:25编辑过]
Fight to win or die...