YorKnEz

Untitled

Jan 27th, 2022
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main () {
  7. char c[11], s[101], *p1, *p2, *p3;
  8. bool exista;
  9.  
  10. cin >> c; cin.get(); cin.getline(s, 101);
  11.  
  12. p3 = strtok(s, " ");
  13. strcpy(p1, p3);
  14. p3 = strtok(NULL, " ");
  15. strcpy(p2, p3);
  16. p3 = strtok(NULL, " ");
  17.  
  18. // p1 = strtok(s, " ");
  19. // p2 = strtok(NULL, " ");
  20. // p3 = strtok(NULL, " ");
  21.  
  22. if ((!p1) || (!p2) || (!p3)) {
  23. cout << "NU EXISTA";
  24. return 0;
  25. }
  26.  
  27. while (p3) {
  28. if (!strcmp(c, p2)) {
  29. cout << p1 << " " << p2 << "\n";
  30. exista = true;
  31. }
  32.  
  33. strcpy(p1, p2);
  34. strcpy(p2, p3);
  35. p3 = strtok(NULL, " ");
  36. }
  37.  
  38. if (!exista) cout << "NU EXISTA";
  39.  
  40. return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment