Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int len(char *s)
- {
- int ans = 0;
- while (*s != 0)
- s++, ans++;
- return ans;
- }
- int main()
- {
- char s[100], t[100];
- scanf("%s%s", s, t);
- int n = len(s), m = len(t), min;
- if (n > m)
- min = n;
- else
- min = m;
- for (int ans = min; ans > 0; ans--)
- for (int i = 0; i + ans <= n; i++)
- for (int j = 0; j + ans <= m; j++)
- {
- int isSubstr = 1;
- for (int k = 0; k < ans; k++)
- {
- if (s[i + k] != t[j + k])
- isSubstr = 0;
- }
- if (isSubstr == 1)
- {
- for (int k = 0; k < ans; k++)
- printf("%c", s[i + k]);
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement