void tofh(int ndisk,char source,char temp,char dest) { if(n disk==1) { printf("move disk %d from %c--->%c\n",ndisk,source,dest); return; } tofh(n disk-1,source,dest,temp) printf("move disk%d from%c--->%c\n",ndisk,source,dest); tofh(ndisk-1,temp,source dest); }
void tofh(int ndisk, char source, char temp, char dest) { if(ndisk==1) { printf("Move Disk %d from %c-->%c\n", ndisk, source, dest); return; } tofh(ndisk-1, source, dest, temp); printf("Move Disk %d from %c-->%c\n", ndisk, source, dest); tofh(ndisk-1, temp, source, dest); }/*End of tofh( )*/
main( ) { char source = 'A', temp = 'B', dest = 'C'; int ndisk; printf("Enter the number of disks : "); scanf("%d", &ndisk ); printf("Sequence is :\n"); tofh(ndisk, source, temp, dest); }/*End of main()*/
int main() { char source='a',temp='b',dest='c'; int disk; printf("enter the no of disk:"); scanf("%d",&disk); printf("sequence is:\n"); tofh(n disk,source,temp,dest); return 0: }