-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab_FilesProcessing.cpp
104 lines (101 loc) · 2.66 KB
/
Lab_FilesProcessing.cpp
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
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char* argv[]) {
string input_filename=argv[1];
string output_filename=argv[2];
ifstream input_file;
fstream output_file;
input_file.open(input_filename);
output_file.open(output_filename, ios::out);
string a,b;
while(getline(input_file,a)){
b+=a;b+="\n";
}
input_file.close();
int state=0;
for(unsigned long long int i=0;i<b.size();i++){
char c=b[i];
switch(state){
case 0:
if(c=='/')
state=1;
else if(c=='\'')
state=6;
else if(c=='\"')
state=8;
else
output_file<<c;
break;
case 1:
if(c=='*')
state=2;
else if(c=='/')
state=4;
else{
output_file<<'/';
output_file<<c;
state=0;
}
break;
case 2:
if(c=='*')
state=3;
else
state=2;
break;
case 3:
if(c=='/')
state=0;
else if(c=='*')
state=3;
else
state=2;
break;
case 4:
if(c=='\\')
state=5;
else if(c=='\n')
{
state=0;
output_file<<c;
}
break;
case 5:
if(c=='\\')
state=5;
else
state=4;
break;
case 6:
if(c=='\\')
state=7;
else if(c=='\'')
{
state=0;
output_file<<c;
}
break;
case 7:
state=6;
break;
case 8:
if(c=='\\')
state=9;
else if(c=='\"')
{
state=0;
output_file<<c;
}
break;
case 9:
state=8;
break;
}
if(state==6||state==7||state==8||state==9)
output_file<<c;
}
output_file.close();
return 0;
}