fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <string>
  4. #include <sstream>
  5. #include <iomanip>
  6.  
  7. int main()
  8. {
  9. std::string str = "karl ykral koralli.....abcdef";
  10. std::stringstream ss;
  11.  
  12. std::cout << str << std::endl;
  13.  
  14. for( auto& c : str )
  15. {
  16. if( std::isalpha(c) )
  17. {
  18. if( std::tolower(c) == c )
  19. {
  20. ss << std::setfill('0') << std::setw(2) << (c-'a'+1);
  21. }
  22. }
  23. else
  24. {
  25. ss << c;
  26. }
  27. }
  28.  
  29. std::cout << ss.str() << std::endl;
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
karl ykral koralli.....abcdef
11011812 2511180112 11151801121209.....010203040506