stasek cpp Defines the entry point for the console application include

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// stasek.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include "conv.h"
#include <conio.h>
using namespace std;
void cutString(string &, string &, vector<int> &);
void findFine(string &, string &, vector<string>&, vector<int> &);
int _tmain(int argc, _TCHAR* argv[])
{
ifstream fine;
ifstream word;
string title = "Kursovaya rabota\n\t\t\tGushina Stanislava";
string fileName="";
string FINEuncut="";
string temp = "";
vector<string> wordlist;
string deletedScenes;
string forOut;
vector<int> indexDel;
pair<int, int> white;
white.first = 0;
white.second = 0;
gotoxy(20, 10);
cout << title;
gotoxy(0, 0);
getch();
do{
clrscr();
fileName = "";
cout << "Enter real filename with fineword: ";
getline(cin, fileName);
fine.open(fileName.c_str(), ios::in);
} while(!fine.is_open());
clrscr();
do{
clrscr();
fileName = "";
cout << "Enter real filename with list of word: ";
getline(cin, fileName);
word.open(fileName.c_str(), ios::in);
} while(!word.is_open());
clrscr();
while (!word.eof()) {
temp = "";
word >> temp;
wordlist.push_back(temp);
}
while (!fine.eof()) {
temp = "";
fine >> temp;
temp += " ";
FINEuncut += temp;
}
forOut = FINEuncut;
cutString(FINEuncut, deletedScenes, indexDel);
findFine(deletedScenes, forOut, wordlist, indexDel);
word.close();
fine.close();
cout << forOut;
getch();
return 0;
}
void cutString(string & source, string & destination, vector<int> &addInfo) {
string pattern = " ,.:-/@#$%^&*()_=+!'";
for (int i = 0; i<=source.size()-1; i++){
if (pattern.find(source[i])!=string::npos) {
addInfo.push_back(i);
} else {
destination += source[i];
}
}
}
void findFine(string & source, string &destination, vector<string>& list, vector<int> &addInfo) {
vector<int>::iterator beg=addInfo.begin();
vector<int>::iterator en = addInfo.end();
for (int i = 0; i<=list.size()-1; i++) {
int length = list[i].size();
int pos = source.find(list[i]);
if (pos!=string::npos) {
while (list[i][0]!=destination[pos]) pos++;
destination[pos] = toupper(destination[pos]);
pos++;
length--;
while (length && pos<=destination.size()-1){
if (!count(beg, en, pos)) {
destination[pos] = toupper(destination[pos]);
length--;
}
pos++;
}
}
}
}