fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main() {
  6. char whereToSearch[100], whatINeed[100], foundIt[100] = {0};
  7. cin.getline(whereToSearch, 100);
  8. cin.getline(whatINeed, 100);
  9. int i = 0, x = 0, n = strlen(whereToSearch), m = strlen(whatINeed);
  10. for (int j = 0; j < m; ++j) {
  11. for (; i < n; ++i) {
  12. if (whatINeed[j] == whereToSearch[i]) {
  13. foundIt[j] = whereToSearch[i];
  14. x = i;
  15. ++i;
  16. break;
  17. } else if (i - x != 1 && foundIt[j] > 0) {
  18. j = 0;
  19. x = 0;
  20. break;
  21. }
  22. }
  23. }
  24. int cons = 0;
  25. for (int i = 0; i < m; ++i) {
  26. if (foundIt[i] == whatINeed[i]) {
  27. ++cons;
  28. }
  29. }
  30. if (cons == m) {
  31. cout << "DA";
  32. } else {
  33. cout << "NU";
  34. }
  35. return 0;
  36. }
Success #stdin #stdout 0s 5268KB
stdin
Hai sa mergem
piese
stdout
NU