Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- void extrag(char s1[1001], int start, int stop, char s[1001]) {
- int m = 0;
- for (int i = start; i <= stop; i++) {
- s[m] = s1[i];
- m++;
- }
- s[m] = 0;
- }
- int main() {
- char s1[1001], s2[1001], sub[1001], rez[1001];
- int i, j, st, m, maxi = 0;
- cin.get(s1, 1001);
- cin.get();
- cin.get(s2, 1001);
- int ok = 0;
- i = 0;
- while (i < strlen(s1)) {
- j = strlen(s1) - 1;
- while (i <= j) {
- m = 0;
- for (int k = i; k <= j; k++) {
- sub[m] = s1[k];
- m++;
- }
- sub[m] = 0;
- if (strstr(s2, sub)) {
- if (strlen(sub) > maxi) {
- maxi = strlen(sub);
- strcpy(rez, sub);
- }
- }
- j--;
- }
- i++;
- }
- cout << rez;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement