Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <cstring>
- using namespace std;
- int main()
- {
- char str[255], sub[255];
- int i, j, flag = 1, k = 0;
- cout << "Enter a string: ";
- cin >> str;
- cout << "Enter search substring: ";
- cin >> sub;
- if (strlen(str) != strlen(sub)) (flag = 0);
- for (i = 0; i <= strlen(str); i++)
- {
- for (j = 0; j <= strlen(sub); j++)
- {
- if (str[j] != sub[i]) {
- k++;
- if (k==(strlen(sub)+1)) {
- flag = 0;
- break;
- }
- }
- }
- k = 0;
- }
- cout << endl << "Answer: ";
- if (flag == 1)
- cout << "Yes";
- else
- cout << "No";
- }
Add Comment
Please, Sign In to add comment