Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- int main()
- {
- char s1[20], s2[20];
- cin.get(s1, 19);
- cin.get();
- cin.get(s2, 19);
- char keep[10] = { 0 };
- int count = 0;
- for (int i = 0; i<strlen(s1); i++)
- for (int j = 0; j <strlen(s2); j++)
- if (s1[i] == s2[j])
- {
- count = 0;
- if (i + 1 == strlen(s1) && j==0)
- cout << s1[i] << " ";
- while (s1[i + 1] == s2[j + 1])
- {
- count++; i++; j++;
- }
- if (count != 0)
- {
- strncpy(keep, s2, count+1);
- cout << keep << " ";
- i--; j--;
- }
- }
- cout << endl << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement