15,113,855 members
1.00/5 (1 vote)
See more:
Python
```def cuadrado(width, height):

if width % 2 == 0:
width += 1
if height % 2 ==  0:
height +=1

for row in range(height):
for col in range(width):
if 0 < row < height - 1 and 0 < col < width - 1:
print(" ", end = "")
elif col % 2 == 0:
print("+", end = "")
else:
print("-", end = "")
print()

def main():

main()```

What I have tried:

Python
```def cuadrado(width, height):

if width % 2 == 0:
width += 1
if height % 2 ==  0:
height +=1

for row in range(height):
for col in range(width):
if 0 < row < height - 1 and 0 < col < width - 1:
print(" ", end = "")
elif col % 2 == 0:
cout("+", end = "")
else:
cout("-", end = "")
cout()

def main():

main()```
Posted
Updated 5-Nov-20 0:19am
v3

## Solution 1

It is very similar:
C++
```#include <iostream>
using namespace std;

{
w |= 1;
h |= 1;

for ( size_t r=0; r<h; ++r )
{
for (  size_t c=0; c<w; ++c)
if ( r && r < (h-1) && c && c <(w-1))
cout << ' ';
else if ( c & 1 )
cout << '-';
else
cout << '+';
cout << endl;
}
}

int main()
{
size_t alto, ancho;
cin >> alto;
cin >> ancho;