-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointInCircle.cpp
More file actions
66 lines (53 loc) · 1.38 KB
/
Copy pathPointInCircle.cpp
File metadata and controls
66 lines (53 loc) · 1.38 KB
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
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <vector>
using namespace std;
float distance(float cx, float cy, float px, float py)
{
return sqrtf((px - cx)*(px - cx) + (py - cy)*(py - cy));
}
int main(int argc, char *argv[])
{
ifstream ifs(argv[1]);
string line;
string radiusInfo, pointInfo, centerInfo;
while (getline(ifs, line))
{
stringstream ss(line);
getline(ss, line, ';');
centerInfo = line;
float a = centerInfo.find('(');
float b = centerInfo.find(')');
centerInfo = string(centerInfo.begin() + (a+1), centerInfo.begin() + b);
stringstream ss1(centerInfo);
getline(ss1, centerInfo, ',');
a = (stof(centerInfo));
getline(ss1, centerInfo);
b = stof(centerInfo);
getline(ss, line, ';');
radiusInfo = line;
float c = radiusInfo.find(':');
float d = radiusInfo.size();
radiusInfo = string(radiusInfo.begin() + (c + 2), radiusInfo.begin() + d);
c = stof(radiusInfo);
getline(ss, line, ';');
pointInfo = line;
float e = pointInfo.find('(');
float f = pointInfo.find(')');
pointInfo = string(pointInfo.begin() + (e + 1), pointInfo.begin() + f);
stringstream ss2(pointInfo);
getline(ss2, pointInfo, ',');
e = (stof(pointInfo));
getline(ss2, pointInfo);
f = stof(pointInfo);
if (distance(a, b, e, f) > c)
cout << "false" << endl;
else
cout << "true" << endl;
}
system("pause");
return 0;
}