more tests

This commit is contained in:
Yaossg 2025-03-09 22:28:36 +08:00
parent d0f8b3e0ad
commit 1bcff515b7
22 changed files with 191 additions and 58 deletions

20
test/function/hanoi.c Normal file
View 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');
}