fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <sstream>
  5. #include <algorithm>
  6.  
  7. typedef std::vector<std::wstring> WSV;
  8. typedef std::vector<std::vector<std::wstring::value_type>> WSS;
  9.  
  10.  
  11.  
  12. WSS MakeHoge(std::wstring W) {
  13. std::size_t N = 0;
  14.  
  15. for (auto&o : W) {
  16. if (o == L' ')o = L'\n';
  17. }
  18.  
  19. std::wstringstream wss(W);
  20. std::wstring WS;
  21. WSV SV;
  22. while (std::getline(wss, WS)) {
  23. SV.push_back(WS);
  24. }
  25.  
  26. std::size_t L = 0;
  27.  
  28. for (auto& o : SV) L = std::max(L, o.size());
  29. WSS SS(L);
  30. for (auto& o : SS) {
  31. o.resize(SV.size(),L' ');
  32. }
  33.  
  34. for (std::size_t i = 0; i < SV.size(); i++) {
  35. for (std::size_t j = 0; j < SV[i].size(); j++) {
  36.  
  37. SS[j][SV.size() - i - 1] = SV[i][j];
  38.  
  39. }
  40. }
  41.  
  42. return SS;
  43.  
  44. }
  45.  
  46. bool Show(const WSS& W) {
  47. std::wcout.imbue(std::locale("Japanese"));
  48. for (auto&oo : W) {
  49. for (auto&o : oo) {
  50. std::wcout << o;
  51. }
  52. std::wcout << std::endl;
  53. }
  54. std::wcout<<std::endl;
  55. std::wcout<<std::endl;
  56. std::wcout<<L"わんわんお"<<std::endl;
  57. return true;
  58. }
  59.  
  60. int main() {
  61. std::wstring ws = L"謹賀新年 謹んで初春の お慶びを 申し上げます";
  62. WSS WS;
  63. WS = MakeHoge(ws);
  64. Show(WS);
  65.  
  66.  
  67. return 0;
  68. }
Runtime error #stdin #stdout #stderr 0s 4348KB
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