Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<map>
- #include<string>
- #include<iostream>
- #include<algorithm>
- #include<fstream>
- #include<ostream>
- using namespace std;
- int main(int argc, char **argv){
- setlocale(LC_ALL, "rus");
- map<string, string>dict;
- fstream fs(argv[1]);
- ofstream out("out.txt");
- if (!fs.is_open()){
- cout << "Can not open file" << endl;
- return 1;
- }
- //тут менять меру сходства
- int count;
- string s1;
- int pos;//0-start;1-end;2-с нужной позиции
- int sdvig;//позиция
- cout << "kolvobukv,stroka,0-start;1-end;2-с нужной позиции,позиция:";
- cin >> count >> s1 >> pos >> sdvig;
- bool flag = 0;
- while (!fs.eof()){
- char eng[256], rus[256];
- fs.getline(eng, 256, '$');
- fs.getline(rus, 256);
- string engword(eng), rusword(rus);
- if (engword.length() > count){
- if (pos == 0){
- for (int j = 0; j < count; j++)
- if (s1[j] == engword[j])
- flag = 1;
- else {
- flag = 0;
- break;
- }
- if (flag == 1)
- out << engword << "$" << rusword << endl;
- }
- if (pos == 1){
- for (int j = 0; j < count; j++)
- if (s1[j] == engword[engword.length() - count + j])
- flag = 1;
- else {
- flag = 0;
- break;
- }
- if (flag == 1)
- out << engword << "$" << rusword << endl;
- }
- if (pos == 2){
- for (int j = 0; j < count; j++)
- if (s1[j] == engword[sdvig + j])
- flag = 1;
- else {
- flag = 0;
- break;
- }
- if (flag == 1)
- out << engword << "$" << rusword << endl;
- }
- }
- }
- fs.close();
- out.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement