fork download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <string>
  4.  
  5. std::string yours[] = {
  6. "cxf341",
  7. "rmj441",
  8. "zmw562",
  9. "987abcd"
  10. };
  11.  
  12. auto yours_length = std::end(yours) - std::begin(yours);
  13.  
  14.  
  15. std::string mine[] = {
  16. "cxf341",
  17. "987abcd",
  18. "rmzddd",
  19. "rmj441"
  20. };
  21.  
  22. auto mine_length = std::end(mine) - std::begin(mine);
  23.  
  24.  
  25. int main() {
  26. for (auto i = std::size_t{ 0 }; i < mine_length; ++i)
  27. {
  28. auto matched = false;
  29. for (auto j = std::size_t{ 0 }; j < yours_length && !matched; ++j)
  30. {
  31. if (mine[i] == yours[j]) {
  32. std::cout << mine[i] << " has a match in mine[" << i << "] and yours[" << j << "]\n";
  33. matched = true;
  34. }
  35. }
  36.  
  37. if (!matched) {
  38. std::cout << mine[i] << " has no match in yours.\n";
  39. }
  40. }
  41. }
Success #stdin #stdout 0s 4536KB
stdin
Standard input is empty
stdout
cxf341 has a match in mine[0] and yours[0]
987abcd has a match in mine[1] and yours[3]
rmzddd has no match in yours.
rmj441 has a match in mine[3] and yours[1]