Gaurang2908 / HacktoberFest2023

HacktoberFest'23
1 stars 4 forks source link

tower of hanoi #3

Closed roshanlimbu closed 8 months ago

roshanlimbu commented 8 months ago

include

void towerOfHanoi(int n, char source, char auxiliary, char target) { if (n == 1) { printf("Move disk 1 from %c to %c\n", source, target); return; } towerOfHanoi(n - 1, source, target, auxiliary); printf("Move disk %d from %c to %c\n", n, source, target); towerOfHanoi(n - 1, auxiliary, source, target); }

int main() { int n; printf("Enter the number of disks: "); scanf("%d", &n); towerOfHanoi(n, 'A', 'B', 'C'); return 0; }

roshanlimbu commented 8 months ago

toh dsa solution