0

I'm trying to solve the programming challenge defined here. Basically, I have solved the essence of the question with normal characters, for instance the execution of zoom(7) returns

0000000
0xxxxx0
0x000x0
0x0x0x0
0x000x0
0xxxxx0
0000000

which is the correct pattern.

However, as additional difficulty the characters must be an empty square at the place of 0 and a filled one at the place of x.

If I try to replace those characters I get as result

□□□□□□□��□□□□
�■■■■■□□□□□��□□□□
��□□□��■■■□□□□□��□□□□
���■�□□��■■■□□□□□��□□□□
��□□□��■■■□□□□□��□□□□
�■■■■■□□□□□��□□□□
□□□□□□□��□□□□

I have no idea what causes the problem, if the console cannot print such squares, or if I need some additional specifications when printing the floats, or whatever. I tried defining the squared as suggested in here, but nothing changed at all.

Here's a basic sample returning the 3x3 solution

#include <iostream>
#include <string>

int main() {
    std::string res;

    std::string prim;
    std::string sec;

        //~ prim = "x";         // filled square
        //~ sec = "0";          // empty square

        prim = "■";         // filled square
        sec = "□";          // empty square

    res += sec; res += sec; res += sec; res += "\n";
    res += sec; res += prim; res += sec; res += "\n";
    res += sec; res += sec; res += sec; res += "\n";

    std::cout << res;

    return 0;   
}
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
anfneub
  • 33
  • 5
  • 1
    Welcome to Stack Overflow. Please take the time to read [The Tour](http://stackoverflow.com/tour) and refer to the material from the [Help Center](http://stackoverflow.com/help/asking) what and how you can ask here. – πάντα ῥεῖ May 25 '17 at 21:09
  • My guess would be you need to use `std::wstring` and `std::wcout`, and format the Unicode strings for the characters in a proper C++ format. Not too familiar with that myself, though. – Daniel Schepler May 25 '17 at 23:14

0 Answers0