Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main () {
- char c[11], s[101], *p1, *p2, *p3;
- bool exista;
- cin >> c; cin.get(); cin.getline(s, 101);
- p3 = strtok(s, " ");
- strcpy(p1, p3);
- p3 = strtok(NULL, " ");
- strcpy(p2, p3);
- p3 = strtok(NULL, " ");
- // p1 = strtok(s, " ");
- // p2 = strtok(NULL, " ");
- // p3 = strtok(NULL, " ");
- if ((!p1) || (!p2) || (!p3)) {
- cout << "NU EXISTA";
- return 0;
- }
- while (p3) {
- if (!strcmp(c, p2)) {
- cout << p1 << " " << p2 << "\n";
- exista = true;
- }
- strcpy(p1, p2);
- strcpy(p2, p3);
- p3 = strtok(NULL, " ");
- }
- if (!exista) cout << "NU EXISTA";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment