fork(2) download
  1. #include <cstring>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. const short maxSize = 46;
  6.  
  7. int main() {
  8. int n, matchingLetters;
  9. cin >> n;
  10. cin.ignore();
  11. char *word_1 = new char[maxSize];
  12. char *word_2 = new char[maxSize];
  13. for (int i = 0; i < n; i++) {
  14. matchingLetters = 0;
  15. cin.getline(word_1, maxSize);
  16. cin.getline(word_2, maxSize);
  17. for (int j = 0; j < strlen(word_1); j++) {
  18. for (int k = 0; k < strlen(word_2); k++) {
  19. if (word_1[j] == word_2[k]) {
  20. word_2[k] = '#';
  21. matchingLetters++;
  22. break;
  23. }
  24. }
  25. }
  26. cout << "Case #" << i + 1 << ": " << strlen(word_1) + strlen(word_2) - 2 * matchingLetters << endl;
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 3460KB
stdin
5
lol
lolipop
primate
mathematics
kangaroo
kilimanjaro
sister
sisters
android
andromeda
stdout
Case #1:  4
Case #2:  8
Case #3:  7
Case #4:  1
Case #5:  4