more tests
This commit is contained in:
parent
d0f8b3e0ad
commit
1bcff515b7
22 changed files with 191 additions and 58 deletions
20
test/function/hanoi.c
Normal file
20
test/function/hanoi.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
int printf(char* format, ...);
|
||||
|
||||
void move(char from_rod, char to_rod) {
|
||||
printf("%c --> %c\n", from_rod, to_rod);
|
||||
}
|
||||
|
||||
void hanoi(int n, char from_rod, char to_rod, char aux_rod) {
|
||||
if (n == 1) {
|
||||
move(from_rod, to_rod);
|
||||
return;
|
||||
}
|
||||
hanoi(n - 1, from_rod, aux_rod, to_rod);
|
||||
move(from_rod, to_rod);
|
||||
hanoi(n - 1, aux_rod, to_rod, from_rod);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n = 3;
|
||||
hanoi(n, 'A', 'C', 'B');
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue