Guest User

Untitled

a guest
Feb 25th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. char str[255], sub[255];
  10. int i, j, flag = 1, k = 0;
  11.  
  12. cout << "Enter a string: ";
  13. cin >> str;
  14. cout << "Enter search substring: ";
  15. cin >> sub;
  16.  
  17. if (strlen(str) != strlen(sub)) (flag = 0);
  18.  
  19. for (i = 0; i <= strlen(str); i++)
  20. {
  21. for (j = 0; j <= strlen(sub); j++)
  22. {
  23. if (str[j] != sub[i]) {
  24. k++;
  25. if (k==(strlen(sub)+1)) {
  26. flag = 0;
  27. break;
  28. }
  29. }
  30. }
  31. k = 0;
  32. }
  33. cout << endl << "Answer: ";
  34. if (flag == 1)
  35. cout << "Yes";
  36. else
  37. cout << "No";
  38. }
Add Comment
Please, Sign In to add comment