fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main() {
  6. bool existaInvitati = false;
  7. char listaInvitati[250], separatori[3] = "; ", x[250], *prenume, *nume;
  8. cin.getline(listaInvitati, 250);
  9. cin >> x;
  10. //cout << listaInvitati << endl;
  11. //cout << x << endl;
  12. prenume = strtok(listaInvitati, separatori);
  13. while (prenume != NULL) {
  14. nume = strtok(NULL, separatori);
  15. char p[250], n[250];
  16. strcpy(p, prenume);
  17. strcpy(n, nume);
  18. //cout << p << ' ' << x << endl;
  19. if (!strcmp(p, x)) {
  20. existaInvitati = true;
  21. cout << n << ' ';
  22. }
  23. prenume = strtok(NULL, separatori);
  24. }
  25. if (!existaInvitati) {
  26. cout << "NU";
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5392KB
stdin
DAN MARIS; DANILA PREPELEAC; DAN POPA; EDANA DAN;
TEODOR
stdout
NU