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;
}