Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- struct Plag_check {
- string s;
- string word[1000];
- int k = 0;
- };
- Plag_check str[1000];
- void String_normalization(int i)
- {
- string ans = str[i].s;
- for (int i = 0; i < ans.length(); i++)
- {
- if (ans[i] >= '0' && ans[i] <= '9')
- continue;
- if (ans[i] >= 'a' && ans[i] <= 'z')
- continue;
- if (ans[i] == ' ')
- continue;
- if (ans[i] >= 'A' && ans[i] <= 'Z')
- {
- ans[i] += 32;
- continue;
- }
- ans.erase(i, 1);
- i--;
- }
- for (int i = 0, k = 0; i < ans.length(); i++)
- {
- if ((ans[i] >= 'a' && ans[i] <= 'z') || (ans[i] >= '0' && ans[i] <= '9'))
- k++;
- else
- {
- if (i == 0 || ans[i - 1] == ' ')
- {
- ans.erase(i, 1);
- i--;
- }
- else if (k > 0 && k <= 3)
- {
- ans.erase(i - k, k + 1);
- i -= k + 1;
- }
- k = 0;
- }
- if (i == ans.length() - 1 && ans[i] != ' ')
- {
- if (k > 0 && k <= 3)
- {
- ans.erase(i - k + 1, k);
- }
- }
- }
- str[i].s = ans;
- }
- float cword(int i, int j)
- {
- float c = 0;
- float g = 0;
- for (int k = 0; k < str[i].word[k].length(); k++)
- {
- for (int l = 0; l < str[j].word[l].length(); l++)
- {
- for (int m = 0; m < str[i].word[k].length() && m < str[j].word[l].length(); m++)
- if (str[i].word[k][m] == str[j].word[l][m])
- c++;
- if (c / (str[i].word[k].length() + str[j].word[l].length() - c) > 0.45)
- g++;
- c = 0;
- }
- }
- return g;
- }
- void cstr(int i, int j)
- {
- float c_word = cword(i, j);
- if (c_word / (str[i].k + str[j].k - c_word) > 0.25)
- {
- cout << "";
- cout << i + 1 << " " << j + 1 << endl;
- }
- }
- int main()
- {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- string s;
- int n = 0;
- int c = 0;
- while (getline(cin, s))
- {
- str[n].s = s;
- n++;
- }
- for (int i = 0; i < n; i++)
- {
- String_normalization(i);
- }
- for (int i = 0; i < n; i++)
- {
- c = 0;
- for (int j = 0; j < str[i].s.length(); j++)
- {
- while (str[i].s[j] != ' ' && j<str[i].s.length())
- {
- str[i].word[c] = str[i].word[c] + str[i].s[j];
- j++;
- }
- c++;
- str[i].k++;
- }
- }
- for (int i = 0; i < n - 1; i++)
- {
- for (int j = i + 1; j < n; j++)
- {
- cstr(i, j);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement