STANAANDREY

MY SIM SB3 2

Apr 5th, 2022 (edited)
945
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #define SEP " ;"
  4. #define NMAX 250
  5. using namespace std;
  6.  
  7. char s[NMAX], x[NMAX];
  8.  
  9. int main() {
  10.     cin.getline(s, NMAX);
  11.     cin >> x;
  12.     char *p = strtok(s, SEP);
  13.     int ok = 0;
  14.     while (p) {
  15.         if (!strcmp(p, x)) {
  16.             p = strtok(NULL, SEP);
  17.             cout << p << ' ';
  18.             ok = 1;
  19.         } else {
  20.             p = strtok(NULL, SEP);
  21.         }
  22.         p = strtok(NULL, SEP);
  23.     }
  24.     if (!ok) {
  25.         cout << "NU" << endl;
  26.     }
  27.     return 0;
  28. }
  29.  
Add Comment
Please, Sign In to add comment