code.cpp 564 B

1234567891011121314
  1. /* A pair of strings form a strange pair if:
  2. * 1st string's first letter = 2nd string's last letter.
  3. * 1st string's last letter = 2nd string's first letter.
  4. * Create a function that returns true if a pair of strings
  5. * constitutes a strange pair, and false otherwise.
  6. */
  7. /* compare wordA first character with wordB last character
  8. * compare wordA last character with wordB first character
  9. * return true if both comparisons are equal
  10. */
  11. bool isStrangePair(std::string str1, std::string str2) {
  12. return str1[0]==str2.back() && str1.back()==str2[0];
  13. }