You may write a function for edge (i.e. top and bottom) lines, like the following:
void edge_line(int row, int length)
{
for (int col=0; col < length; ++col)
{
char c = 'a'+ row - 32 * (col & 1);
cout << c;
}
cout << '\n';
}
Similarly, you may write the code for the middle line function.
Eventually you have to call them:
edge_line(0, length);
for (row = 1; row < (width-1)); ++row)
middle_line(row, length);
edge_line((width-1), length);
That's all.