Skip to content

Instantly share code, notes, and snippets.

@dc1394
Created March 9, 2015 12:48
Show Gist options
  • Save dc1394/d3709bbaf58beef502c4 to your computer and use it in GitHub Desktop.
Save dc1394/d3709bbaf58beef502c4 to your computer and use it in GitHub Desktop.
#include <complex>
#include <iostream>
#include <locale>
#include <string>
int main()
{
std::wstring const haiku = { L"島々に    灯をともしけり春の海       正岡子規" };
std::complex<int> c(3, 0), cp(c);
std::complex<int> const r(-1, 0), i(0, 1);
std::ios_base::sync_with_stdio(false);
std::locale::global(std::locale(""));
std::wcout.imbue(std::locale(""));
for (auto a = 0; a < 21; a++, c += r) {
if (!c.real()) {
std::wcout << haiku[7 * c.real() + c.imag()] << std::endl;
cp += i;
c = cp;
}
std::wcout << haiku[7 * c.real() + c.imag()];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment