fork download
  1. #include <iostream>
  2. #include <map>
  3.  
  4. void handle_case(const std::string& input)
  5. {
  6. std::map<char, int> character_count;
  7.  
  8. for(char c: input)
  9. {
  10. if(++character_count[c] > 1)
  11. {
  12. std::cout << input << " : " << c << " : " << input.find(c) << std::endl;
  13. return;
  14. }
  15. }
  16. std::cout << "Np duplicates were found." << std::endl;
  17. }
  18. int main()
  19. {
  20. std::string input;
  21. while(getline(std::cin, input))
  22. {
  23. handle_case(input);
  24. }
  25. }
Success #stdin #stdout 0s 16064KB
stdin
ABCDEBC
IKEUNFUVFV
PXLJOUDJVZGQHLBHGXIW
*l1J?)yn%R[}9~1"=k7]9;0[$
stdout
ABCDEBC : B : 1
IKEUNFUVFV : U : 3
PXLJOUDJVZGQHLBHGXIW : J : 3
*l1J?)yn%R[}9~1"=k7]9;0[$ : 1 : 2