Ciężki przypadek :P
int main()
{
int n = 10;
n = n / 2 + 1; // prawdziwe n
for (size_t i = 0; i < n; i++)
{
for (size_t j = 0; j < n; j++)
{
if (i % (n - 1) == 0 || j % (n - 1) == 0) //pelna ramka
cout << 'x';
else if (i % (n - 3) == 1 || j % (n - 3) == 1) //pusta ramka
cout << '.';
else //srodek
cout << 'x';
}
cout << endl;
}
}
Ale chyba bardziej czytelnie byłoby użyć konstruktor stringa:
int n = 9;
n = n / 2 + 1; // prawdziwe n
string edge(n, 'x');
string edge_minus_1 = "x" + string(n - 2, '.') + "x";
string inside = "x." + string(n - 4, 'x') + ".x";
cout << edge << endl << edge_minus_1 << endl;
for (size_t i = 0; i < n - 4; i++)
{
cout << inside << endl;
}
cout << edge_minus_1 << endl << edge << endl;