Hi,I have a question in below code.
in tower function in else, do act all of statement ?(I cant speak English well,sorry).
Tanks
Code:
#include <stdio.h>
#include <conio.h>
#include <iostream>
void tower(int,char,char,char);
int main()
{
int ndisk;
system("cls");
printf("\nEnter number of disks : ");
scanf("%d",&ndisk);
tower(ndisk,'A','B','C');
getch();
return 0;
}//end of main()
void tower(int topN, char src,char aux,char dest)
{
if(topN == 1)
{
printf("\n Disk 1 from %c to %c ",src,dest);
}
else
{
tower(topN-1,src,dest,aux); //src to aux
printf("\n Disk %d from %c to %c ",topN,src,dest);
tower(topN-1,aux,src,dest); //aux to dest
}
}//end of tower()