解题思路:
又是板子题,,,第二题有点失望
注意事项:
参考代码:
#pragma comment(linker, "/STACK:1024000000, 1024000000")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
void mov(int cur, char a, char b, char c) {
if(cur == 1) {
printf("Move %d from %c to %c\n",cur,a,c);
}
else {
mov(cur-1,a,c,b);
printf("Move %d from %c to %c\n",cur,a,c);
mov(cur-1,b,a,c);
}
}
int main()
{
//freopen("in.txt","r",stdin);
scanf("%d",&n);
mov(n,'1','2','3');
return 0;
}
0.0分
1 人评分