hanoi tower
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <stdio.h> void hanoi_tower (int number, char from, char temporary, char to); int main (int argc, char** argv) { hanoi_tower (3, 'A', 'B', 'C'); return 0; } void hanoi_tower (int number, char from, char temporary, char to) { if (number == 1) { printf ("Moved disk 1 form %c to %c\n", from, to); return; } hanoi_tower (number - 1, from, to, temporary); printf ("Moved disk %i form %c to %c\n", number, from, to); hanoi_tower (number - 1, temporary, from, to); return; } | cs |
0 개의 댓글:
댓글 쓰기