不知道最后四行的规律,就只好这样了…
#include<iostream>
using namespace std;
int n;
char a[210];
void print() {
for (int i = 1; i <= 2 * n + 2; i++) {
cout << a[i];
}
cout << endl;
}
void print2() {
for (int i = 1; i <= 2 * n - 7; i++) {
if (i % 2 == 1)
cout << "*";
else cout << "o";
}
cout << endl;
}
void move(int n, int l) {
if (l == 9) {
a[n] = a[n + 1] = '-';
a[l] = 'o';
a[l + 1] = '*';
print();
cout << "ooo*o**--";
print2();
cout << "o--*o**oo";
print2();
cout << "o*o*o*--o";
print2();
cout << "--o*o*o*o";
print2();
}
else {
a[n] = a[n + 1] = '-';
a[l] = 'o';
a[l + 1] = '*';
print();
a[n] = a[n + 1] = '*';
a[l - 2] = a[l - 1] = '-';
print();
move(n - 1, l - 2);
}
}
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
a[i] = 'o';
for (int i = n + 1; i <= 2 * n; i++)
a[i] = '*';
a[2 * n + 1] = a[2 * n + 2] = '-';
print();
move(n, 2 * n + 1);
return 0;
}