Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- int main() {
- char s1[55], s2[55];
- int len1, len2, maior, qtd, y, x, z;
- memset(s1, '\0', 55);
- memset(s2, '\0', 55);
- while( gets(s1) != NULL ) {
- gets(s2);
- len1 = strlen(s1);
- len2 = strlen(s2);
- maior = 0;
- for(x = 0; x < len1; x++) {
- z = x;
- qtd = 0;
- for(y = 0; y < len2 && z < len1; y++) {
- if(s1[z] == s2[y]) {
- qtd++;
- if(qtd > maior) {
- maior = qtd;
- }
- z++;
- } else {
- if(qtd > maior) {
- maior = qtd;
- }
- qtd = 0;
- z = x;
- }
- }
- }
- printf("%d\n", maior);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement