fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <thread>
  4.  
  5. //唐突にエスケープシーケンスを使ってるよ。
  6. //http://7...content-available-to-author-only...m.net/etc/esc.html
  7.  
  8. bool MakeHoge(std::size_t L_,const std::chrono::milliseconds& Wait) {
  9. std::wstring S = L"(´・ω・`)";//'('&')'が半角なので表示位置がずれる。半角は1バイト分の表示の様である。
  10. int L = L_;
  11. int C = 1;
  12. int P = 1;
  13. int k = S.size()*C;
  14. int j = 0;
  15. int SS = S.size()+2;
  16.  
  17. do{
  18. for (k = (SS*C); k < L; k++) {
  19. for (j = (SS*C); j < k; j++) {
  20. std::wcout << L' ';
  21. }
  22. for (int i = 0; i < C; i++) {
  23. std::wcout << S;
  24. }
  25. std::wcout << L"\033[0K" << L'\r';
  26. std::this_thread::sleep_for(std::chrono::milliseconds(Wait));
  27. }
  28. if ((C+1) * SS > L) { P = -1; }
  29. C+=P;
  30. if (!C) { break; }
  31.  
  32. for (k -= (SS*C); k >= 0; k--) {
  33. for (j = 0; j < k; j++) {
  34. std::wcout << L' ';
  35. }
  36. for (int i = 0; i < C; i++) {
  37. std::wcout << S;
  38. }
  39. std::wcout << L"\033[0K" << L'\r';
  40. std::this_thread::sleep_for(std::chrono::milliseconds(Wait));
  41.  
  42. }
  43. if ((C+1) * SS > L) { P = -1; }
  44. C+=P;
  45. } while (C);
  46.  
  47.  
  48. return true;
  49. }
  50.  
  51. int main() {
  52. auto Loc = std::wcout.imbue(std::locale("Japanese"));
  53.  
  54. MakeHoge(80, std::chrono::milliseconds{ 16 });
  55.  
  56. std::wcout.imbue(Loc);
  57. return 0;
  58. }
Runtime error #stdin #stdout #stderr 0s 4540KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::runtime_error'
  what():  locale::facet::_S_create_c_locale name not valid