fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4. using namespace std;
  5. const int MAX_LEN = 1000;
  6. string first_list[MAX_LEN];
  7. string second_list[MAX_LEN];
  8. string third_list[MAX_LEN];
  9.  
  10. int is_letter(char c) {
  11. if ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z') {
  12. return 1;
  13. }
  14. return 0;
  15. }
  16.  
  17. int main() {
  18. int n;
  19. cin >> n;
  20. getline(cin, first_list[0]);
  21. getline(cin, second_list[0]);
  22. getline(cin, third_list[0]);
  23. for (int i = 0; i < n ; ++i) {
  24. getline(cin, first_list[i]);
  25. getline(cin, second_list[i]);
  26. getline(cin, third_list[i]);
  27. int first_len = first_list[i].size();
  28. int second_len = second_list[i].size();
  29. int third_len = third_list[i].size();
  30. string word_first, word_second, word_third, word_last;
  31. int counter = 0;
  32. int is_word_first = 0, counter_letter_first = 0;
  33. int is_word_second = 0, counter_letter_second = 0;
  34. for (int j = 0; j < first_len; ++j) {
  35. if (is_letter(first_list[i][j])) {
  36. is_word_first = 1;
  37. ++counter_letter_first;
  38. } else if (is_word_first == 1){
  39. is_word_first = 0;
  40. for (int x = 0; x <= counter_letter_first; ++x) {
  41. word_first += first_list[i][x];
  42. }
  43. is_word_first = 0;
  44. for (int k = 0; k < second_len; ++k) {
  45. if (is_letter(second_list[i][k])) {
  46. is_word_second == 1;
  47. ++counter_letter_second;
  48. } else if (is_word_second == 1) {
  49. cout << counter_letter_second << " ";
  50. for (int x = 0; x <= counter_letter_second; ++x) {
  51. word_second += second_list[i][x];
  52. }
  53. is_word_second = 0;
  54. counter_letter_second = 0;
  55. if (word_third.compare(word_second) == 0) {
  56.  
  57. } else {
  58. for (int p = 0; p < first_len; ++p) {
  59. if (is_letter(first_list[i][p]) == 0) {
  60. word_first += first_list[i][p];
  61. } else {
  62. if (word_third.compare(word_first) == 0) {
  63. word_last = word_third;
  64. }
  65. }
  66. }
  67. }
  68. }
  69. }
  70. }
  71. }
  72. }
  73. return 0;
  74. }
  75.  
Success #stdin #stdout 0s 5348KB
stdin
3
car apple computer
masina mar calculator
computer car apple
stdout
Standard output is empty