fork download
  1. #include <cstdio>
  2. #include <cctype>
  3. #include <string>
  4.  
  5. const int Nx = 3;
  6. const int Ny = 3;
  7. const std::string Chars[Ny][Nx] = {
  8. "1", "2", "3",
  9. "4", "5", "6",
  10. "7", "8", "9"
  11. }
  12.  
  13. ;int main(void) {
  14. // 文字列置換
  15. for (int y = 0; y < Ny; y++) {
  16. for (int x = 0; x < Nx; x++) {
  17. std::string& str = *((std::string *)&Chars[y][x]);
  18. for (std::string::iterator it = str.begin(); it != str.end(); it++) {
  19. if (isdigit(*it) && *it != '0') *it = *it - '1' + 'a';
  20. }
  21. }
  22. }
  23. // テスト出力
  24. for (int y = 0; y < Ny; y++) {
  25. for (int x = 0; x < Nx; x++) {
  26. if (x > 0) putchar(',');
  27. printf("\"%s\"", Chars[y][x].c_str());
  28. }
  29. putchar('\n');
  30. }
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
"a","b","c"
"d","e","f"
"g","h","i"