-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcensor.cpp
More file actions
43 lines (37 loc) · 730 Bytes
/
Copy pathcensor.cpp
File metadata and controls
43 lines (37 loc) · 730 Bytes
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
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <math.h>
#include <climits>
using namespace std;
int main()
{
std::ifstream fin ("censor.in");
std::ofstream fout ("censor.out");
string word;
string censor;
fin >> word >> censor;
cout << word << ' ' << censor << endl;
int n = 1;
while (n != 0)
{
n = 0;
string wcopy (word);
int x = word.length() - censor.length();
cout << x << endl;
for (int i = 0; i <= x; i++){
string check (wcopy, i, censor.length());
if(check == censor){
word.erase (i,censor.length());
cout << word << endl;
n = n + 1;
}
n = n - 1;
cout << n << endl;
}
cout << n << endl;
n = n + x;
}
fout << word << endl;
}