Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //205
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <math.h>
- #include <string>
- #include <algorithm>
- #include <climits>
- using namespace std;
- double gakkar(string s1, string s2)
- {
- double c = 0;
- if (s1.length() <= s2.length())
- {
- for (int i = 0; i < s1.length(); i++) {
- if (s1[i] == s2[i])
- c++;
- }
- }
- else
- {
- for (int i = 0; i < s2.length(); i++)
- if (s1[i] == s2[i])
- c++;
- }
- c = c / (s1.length() + s2.length() - c);
- return c;
- };
- string norm2(string s)
- {
- string x, k;
- int i = 0;
- while ((int)s[i] == 32)
- i++;
- for (; i<s.length(); i++)
- {
- if ((int)s[i] == 32)
- if (k.length() > 3)
- {
- x = x + k + " ";
- k = "";
- }
- else
- k = "";
- else
- k = k + s[i];
- }
- if (k.length() > 3)
- x = x + k;
- return x;
- }
- string norm1(string s)
- {
- string x;
- for (int i = 0; i < s.length(); i++)
- {
- int a = (int)s[i];
- if ((a == 32) || ((a >= 48) && (a <= 57)) || ((a >= 97) && (a <= 122)))
- x = x + s[i];
- if ((a >= 65) && (a <= 90))
- {
- s[i] += 32;
- x = x + s[i];
- }
- }
- return x;
- };
- int main()
- {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- string s1,s2, m;
- getline(cin, s1);
- getline(cin, s2);
- s1 = norm1(s1);
- s1 = norm2(s1);
- s2 = norm1(s2);
- s2 = norm2(s2);
- cout.precision(8);
- cout << fixed << gakkar(s1, s2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement