-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlines.cpp
114 lines (114 loc) · 1.44 KB
/
lines.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
105
106
107
108
109
110
111
112
113
114
#include<iostream>
#include<cstring>
#include<fstream>
#include<streambuf>
using namespace std;
ifstream a("file.txt");
string s((istreambuf_iterator<char>(a)),istreambuf_iterator<char>());
int main()
{
int i,j,k,n,m,x,y;
i=0;
j=0;
k=0;
n=0;
m=s.length();
while (i<m)
{
if ((s[i]==' ')||(s[i]=='\r')||(s[i]=='\t'))
{
i++;
continue;
}
if (s[i]=='\n')
{
if (j==1)
{
n++;
j=0;
}
i++;
continue;
}
if (s[i]=='\"')
{
while (1>0)
{
i++;
if (i>=m) break;
if (s[i]=='\"')
{
x=i;
y=0;
while (1>0)
{
x--;
if ((s[x]=='\\')&&(x>=0)) y++;
else break;
}
if (y%2==0) break;
}
if (s[i]=='\n')
{
n++;
j=1;
}
}
j=1;
i++;
continue;
}
if ((s[i]=='/')&&(s[i+1]=='/')&&(i<m-1))
{
if (j==1)
{
n++;
j=0;
}
i++;
while ((i<m)&&(s[i]!='\n')) i++;
i++;
continue;
}
if ((s[i]=='/')&&(i<m-1))
{
if (s[i+1]=='*')
{
i++;
while (1>0)
{
i++;
if (i>=m) break;
if (s[i]=='\n')
{
if (k==0)
{
if (j==1)
{
n++;
j==0;
}
k==1;
}
}
if ((s[i]=='*')&&(i<m-1))
{
if (s[i+1]=='/')
{
i++;
break;
}
}
}
k==0;
i++;
continue;
}
}
j=1;
i++;
}
if (j==1) n++;
cout<<n;
return 0;
}