解题思路:
又是板子题,,,第二题有点失望
注意事项:
参考代码:
#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 人评分
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:1029 |
C语言训练-求函数值 (C语言代码)浏览:573 |
WU-输入输出格式练习 (C++代码)浏览:1076 |
C语言程序设计教程(第三版)课后习题6.8 (C语言代码)浏览:522 |
字符逆序 (C语言代码)浏览:636 |
蚂蚁感冒 (C语言代码)浏览:1319 |
A+B for Input-Output Practice (C语言代码)浏览:458 |
1126题解浏览:578 |
大家好,我是验题君浏览:576 |
震宇大神的杀毒软件 (C语言代码)浏览:1079 |