fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. std::string str;
  7. std::getline(std::cin, str);
  8. auto first_k = str.find_first_of("k");
  9. auto last_c = str.find_last_of("c");
  10. if ( first_k != std::string::npos ) str[first_k] = 'c';
  11. if ( last_c != std::string::npos ) str[last_c] = 'k';
  12. std::cout << str;
  13. return 0;
  14. }
Success #stdin #stdout 0s 2988KB
stdin
kkc
stdout
ckk