Data_Structure/作業/unit5/river_in_tower.cpp

26 lines
319 B
C++
Raw Normal View History

2025-01-20 21:30:53 +08:00
#include <stdio.h>
void move(int n, char A, char B, char C)
{
if (n == 1) {
printf("<EFBFBD><EFBFBD><EFBFBD>L1<EFBFBD>q%c<>ηh<CEB7><68>%c<><63>\n",A,C);
return;
}
move(n-1,A,C,B);
printf("<EFBFBD><EFBFBD><EFBFBD>L%d<>q%c<>ηh<CEB7><68>%c<><63>\n",n,A,C);
move(n-1,B,A,C);
}
int main()
{
int n = 3; /* <20><><EFBFBD>L<EFBFBD>`<60><> */
move(n,'A','B','C'); /* A<>BB<42>BC<42>O<EFBFBD>άW<CEAC><57><EFBFBD>W<EFBFBD><57> */
return 0;
}