Advertisement
Norby9

Untitled

Mar 21st, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. void extrag(char s1[1001], int start, int stop, char s[1001]) {
  6.   int m = 0;
  7.   for (int i = start; i <= stop; i++) {
  8.     s[m] = s1[i];
  9.     m++;
  10.   }
  11.   s[m] = 0;
  12. }
  13.  
  14. int main() {
  15.   char s1[1001], s2[1001], sub[1001], rez[1001];
  16.   int i, j, st, m, maxi = 0;
  17.   cin.get(s1, 1001);
  18.   cin.get();
  19.   cin.get(s2, 1001);
  20.   int ok = 0;
  21.   i = 0;
  22.   while (i < strlen(s1)) {
  23.     j = strlen(s1) - 1;
  24.     while (i <= j) {
  25.       m = 0;
  26.       for (int k = i; k <= j; k++) {
  27.         sub[m] = s1[k];
  28.         m++;
  29.       }
  30.       sub[m] = 0;
  31.       if (strstr(s2, sub)) {
  32.         if (strlen(sub) > maxi) {
  33.           maxi = strlen(sub);
  34.           strcpy(rez, sub);
  35.         }
  36.       }
  37.       j--;
  38.     }
  39.     i++;
  40.   }
  41.   cout << rez;
  42.   return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement