fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. std::string str;
  7. std::cin >> str;
  8.  
  9. std::string findA = "A";
  10. std::string replaceWith = "10";
  11.  
  12. size_t pos = 0;
  13. while ((pos = str.find(findA, pos)) != std::string::npos)
  14. {
  15. str.replace(pos, findA.length(), replaceWith);
  16. pos += replaceWith.length();
  17. }
  18.  
  19. std::cout << str << std::endl;
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 4432KB
stdin
AstringwithAsandA
stdout
10stringwith10sand10