你这样例都过不去吧
by InversionShadow @ 2023-03-27 18:37:00
@[yuandingquan1101](/user/672281) SPJ合理即可吧
by Maysoul @ 2023-03-27 18:55:53
@[Maysoul](/user/409774) SPJ 返回的结果说明你的有些移动不合法
by fengziyi @ 2023-03-27 19:28:16
```cpp
#include <cstdio>
#include <iostream>
using namespace std;
int n;
char ch[205];
void swap(char &a, char &b)
{
char t = a;
a = b;
b = t;
}
void output(){
for (int i = 0; i < 2 * n + 2; i++)
putchar(ch[i]);
putchar('\n');
}
void movechess(int start, int end)
{
swap(ch[start], ch[end]);
swap(ch[start + 1], ch[end + 1]);
output();
}
string out[4] = {"ooo*o**--*", "o--*o**oo*", "o*o*o*--o*", "--o*o*o*o*"};
int main()
{
scanf("%d", &n);
for (int i = 0; i < n; i++)
ch[i] = 'o';
for (int i = n; i < 2 * n; i++)
ch[i] = '*';
ch[2 * n] = '-';
ch[2 * n + 1] = '-';
output();
int len = n;
while (true)
{
movechess(len - 1, 2 * len);
len--;
if (len == 3)
break;
movechess(len, 2 * len);
}
string ss;
for (int i = 0; i < n - 4; i++)
ss += "o*";
for (int i = 0; i < 4; i++)
cout << out[i] << ss << endl;
}
求关注
by lienze2012 @ 2023-04-03 20:52:54