-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstarter.cpp
More file actions
90 lines (77 loc) · 2.41 KB
/
Copy pathstarter.cpp
File metadata and controls
90 lines (77 loc) · 2.41 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// start.cpp
#include "input.hpp"
#include "distance.hpp"
#include "name_creator.hpp"
#include <iostream>
int StartLoop()
{
float start_lat;
std::string start_ns;
float start_lon;
std::string start_ew;
std::string start_name;
std::cin >> start_lat >> start_ns >> start_lon >> start_ew;
std::cin.ignore(1); // just added ------------------------------------------
std::getline(std::cin,start_name);
if (start_ns == "/S" )
{
start_lat *= -1;
}
if (start_ew == "/E")
{
start_lon *=-1;
}
int target;
// std::cout << CreateLocName(start_lat, start_ns, start_lon, start_ew, start_name) << std::endl;
int i=0;
float distance;
float min,max;
min = max = 0;
std::cin >> target;
std::cin.ignore(1);
// std::cout << target << std::endl;
float dest_lat, dest_lon;
std::string dest_ns,dest_ew,dest_name;
std::string min_name, max_name;
while (target != 0)
{
std::cin >> dest_lat >> dest_ns >> dest_lon >> dest_ew;
std::cin.ignore(1); // Just added ----------------------------------
std::getline(std::cin,dest_name);
// std::cout << CreateLocName(dest_lat,dest_ns,dest_lon, dest_ew,dest_name) <<std::endl;
if (dest_ns == "/S" )
{
dest_lat *= -1.0;
}
if (dest_ew == "/E")
{
dest_lon *=-1.0;
}
distance = DistanceOfTwoLocations(start_lat,start_lon,dest_lat,dest_lon);
if (distance >= max)
{
if (i==0)
{
min = max = distance;
min_name = max_name = CreateLocName(dest_lat,dest_ns,dest_lon,dest_ew,dest_name);
i++;
}
else
{
max = distance;
max_name = CreateLocName(dest_lat,dest_ns,dest_lon,dest_ew,dest_name);
}
}
else
{
min = distance;
min_name = CreateLocName(dest_lat,dest_ns,dest_lon,dest_ew,dest_name);
}
// std::cout << distance << std::endl;
target--;
}
// std::cout << "Start Location: " << start_lat << start_ns << " " << "(" << start_name << ")" << std::endl;
std::string start_full = CreateLocName(start_lat,start_ns, start_lon,start_ew,start_name);
CreateOutputResult(start_full,min_name,max_name,min,max);
return 0;
}