#include <iostream>
#include <string>
#include <thread>
//唐突にエスケープシーケンスを使ってるよ。
//http://7...content-available-to-author-only...m.net/etc/esc.html
bool MakeHoge(std::size_t L_,const std::chrono::milliseconds& Wait) {
std::wstring S = L"(´・ω・`)";//'('&')'が半角なので表示位置がずれる。半角は1バイト分の表示の様である。
int L = L_;
int C = 1;
int P = 1;
int k = S.size()*C;
int j = 0;
int SS = S.size()+2;
do{
for (k = (SS*C); k < L; k++) {
for (j = (SS*C); j < k; j++) {
std::wcout << L' ';
}
for (int i = 0; i < C; i++) {
std::wcout << S;
}
std::wcout << L"\033[0K" << L'\r';
std::this_thread::sleep_for(std::chrono::milliseconds(Wait));
}
if ((C+1) * SS > L) { P = -1; }
C+=P;
if (!C) { break; }
for (k -= (SS*C); k >= 0; k--) {
for (j = 0; j < k; j++) {
std::wcout << L' ';
}
for (int i = 0; i < C; i++) {
std::wcout << S;
}
std::wcout << L"\033[0K" << L'\r';
std::this_thread::sleep_for(std::chrono::milliseconds(Wait));
}
if ((C+1) * SS > L) { P = -1; }
C+=P;
} while (C);
return true;
}
int main() {
auto Loc = std::wcout.imbue(std::locale("Japanese"));
MakeHoge(80, std::chrono::milliseconds{ 16 });
std::wcout.imbue(Loc);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dGhyZWFkPgoKLy/llJDnqoHjgavjgqjjgrnjgrHjg7zjg5fjgrfjg7zjgrHjg7PjgrnjgpLkvb/jgaPjgabjgovjgojjgIIKLy9odHRwOi8vNy4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4ubS5uZXQvZXRjL2VzYy5odG1sCgpib29sIE1ha2VIb2dlKHN0ZDo6c2l6ZV90IExfLGNvbnN0IHN0ZDo6Y2hyb25vOjptaWxsaXNlY29uZHMmIFdhaXQpIHsKCXN0ZDo6d3N0cmluZyBTID0gTCIowrTjg7vPieODu2ApIjsvLycoJyYnKSfjg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