fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. bool isCharacter(char c1[], char c2[]) {
  6. int n = strlen(c1);
  7. int m = strlen(c2);
  8. for (int i = 0; i < n; ++i) {
  9. if ('A' <= c1[i] && 'Z' >= c1[i]) {
  10. return true;
  11. }
  12. }
  13. for (int i = 0; i < m; ++i) {
  14. if ('A' <= c2[i] && 'Z' >= c2[i]) {
  15. return true;
  16. }
  17. }
  18. return false;
  19. }
  20.  
  21. int main() {
  22. char whereToSearch[100], whatINeed[100];
  23. cin.getline(whereToSearch, 100);
  24. cin.getline(whatINeed, 100);
  25. int n = strlen(whereToSearch);
  26. int m = strlen(whatINeed);
  27. bool found = false;
  28. if (n == 0 || m == 0) {
  29. return 0;
  30. }
  31. for (int i = 0; i <= n - m; ++i) {
  32. found = true;
  33. if (isCharacter(whereToSearch, whatINeed)) {
  34. return 0;
  35. }
  36. for (int j = 0; j < m; ++j) {
  37. if (whereToSearch[i + j] != whatINeed[j]) {
  38. found = false;
  39. break;
  40. }
  41. }
  42. if (found) {
  43. cout << "DA";
  44. return 0;
  45. }
  46. }
  47. cout << "NU";
  48. return 0;
  49. }
Success #stdin #stdout 0.01s 5284KB
stdin
123 12 11
11
stdout
DA