Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- int main()
- {
- char s1[100],s2[100];
- int match[100]= {0},i=0,j=0,k=0,count=0,large=0,s1Size=0,result=0;
- cout << "Input 1st string: ";
- gets(s1);
- cout << "Input 2nd String: ";
- gets(s2);
- for (i=0,j=0; s1[i] != '\0' && s2[j] != '\0'; i++,j++)
- {
- s1Size++;
- if(s1[i] == s2[j])
- {
- count++;
- if(s1[i+1] != '\0' && s2[j+1] != '\0')
- {
- continue;
- }
- }
- if(count!=0)
- {
- match[k] = count;
- count = 0;
- k++;
- }
- }
- for(i=0; match[i]!=0; i++)
- {
- if(match[i]>large)
- {
- large = match[i];
- }
- }
- cout << "Highest Matching: " << large << " character" <<endl;
- result = (large*100)/s1Size;
- cout << "Result: " << result << "% Matching" <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment