Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int my_strlen(const char str[])
- {
- int counter= 0;
- while (str[counter] !='\0')
- counter++;
- return counter;
- }
- int my_strcmp(const char str1[], const char str2[], int idx1, int idx2, int size)
- {
- int i;
- for (i=0; i <= size; i++)
- if (str1[idx1+i]!=str2[idx2+i] )
- return 0;
- return 1;
- }
- int strcmp_size(const char str1[], const char str2[], int size)
- {
- int idx1, 1dx2;
- for (idx1=0; str1[idx1]!='\0'; idx1++) {
- for(idx2=0; str2[idx2]!='\0'; idx2++)
- if (mt_strcmp (str1, str2, idx1, idx2) == 1) break;
- return 1; }
- return o;
- }
- int longest_substring(const char str1[], const char str2[])
- {
- int size, max;
- for(size=1; size <= my_strlen(str1) && size <= my_strlen(str2); size++) {
- if strcmp_size(str1, str2, size)==1)
- max=size;
- return max; }
- return0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement