0

i need help to draw hollow square . i am done making completely filled square . anyone pls ?

Edited by pritaeas: Moved to C++

5
Contributors
5
Replies
25
Views
3 Years
Discussion Span
Last Post by gerard4143
0

I can do it with a pencil

Well, if the "completely filled square" is already done, then the hollow square could be done with an eraser!

0

Here's a hollow square. I think?

#include <iostream>

int main(int argc, char** argv)
{
    unsigned int count = 12;

    for (size_t i = 0; i < count; ++i)
    {
        if ( i == 0 )
        {
            std::cout << std::string (count, 'x') << std::endl;
            continue;
        }
        if ( i == count - 1 )
        {
            std::cout << std::string (count, 'x') << std::endl;
            continue;
        }
        std::cout << 'x' << std::string (i - 1, ' ') << std::string (count - i - 1, 'y') << 'x' << std::endl;
    }

    return 0;
}



xxxxxxxxxxxx
xyyyyyyyyyyx
x yyyyyyyyyx
x  yyyyyyyyx
x   yyyyyyyx
x    yyyyyyx
x     yyyyyx
x      yyyyx
x       yyyx
x        yyx
x         yx
xxxxxxxxxxxx

Edited by gerard4143

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.