fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. const int MAX_LEN = 1000;
  5. string first_list[MAX_LEN];
  6. string second_list[MAX_LEN];
  7. string third_list[MAX_LEN];
  8. int is_word(char c) {
  9. if ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z') {
  10. return 1;
  11. }
  12. return 0;
  13. }
  14.  
  15. int main() {
  16. int n;
  17. cin >> n;
  18. getline(cin, first_list[0]);
  19. getline(cin, second_list[0]);
  20. getline(cin, third_list[0]);
  21. for (int i = 0; i < n ; ++i) {
  22. getline(cin, first_list[i]);
  23. getline(cin, second_list[i]);
  24. getline(cin, third_list[i]);
  25. int first_len = first_list[i].size();
  26. int second_len = second_list[i].size();
  27. int third_len = third_list[i].size();
  28. string word;
  29. for (int j = 0; j < third_len; ++j) {
  30. if (is_word(first_list[i][j])) {
  31. for (int k = 0; k < second_len; ++k) {
  32. if (is_word(second_list[i][k])) {
  33. if (first_list[i][j] == second_list[i][k]) {
  34. cout << second_list[i][j] << " ";
  35. }
  36. }
  37. }
  38. }
  39. }
  40.  
  41.  
  42.  
  43.  
  44. }
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0.01s 5384KB
stdin
3
ceas copt promt
masina mar calculator
computer car apple
stdout
c c e e a s s c c o p     p r m t t   �