-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
134 lines (129 loc) · 3.18 KB
/
main.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <iostream>
// including classes
#include "City.h"
#include "Coordinate.h"
#include "CoordinateCalculator.h"
#include "DataFaker.h"
using namespace std;
//
//class Coordinate {
//public:
// int x;
// int y;
//
// Coordinate(int x, int y) {
// this->x = x;
// this->y = y;
// }
//};
//
//class City {
//public:
// bool visited;
// int index;
// int nextCityIndex;
// Coordinate *coordinate;
//
// City(int count) {
// this->visited = 0;
// };
//
// City() {
// }
//};
//
//class Calculator {
//public:
// int count;
//
// Calculator(int count) {
// this->count = count;
// };
//
// CalculateLength(City *cities) {
// int length;
// for (int i = 0; i< this->count; i++) {
// if (i + 1 < this->count) {
// int length = this->getLength(cities[i], cities[i + 1]);
// }
// for (int j = i; j < this->count; j++) {
// if (j + 1 < this->count) {
// int currentLength = this->getLength(cities[i], cities[j + 1]);
// if (currentLength < length) {
// length = currentLength;
//
// cout << j << endl;
// }
// }
//
// }
// }
// }
//
// int getLength(City first, City second) {
// return first.coordinate->x - second.coordinate->x;
// }
//
// int roundLength(int num) {
// return (((int) num * 100) % 100) / 100;
// }
//};
//
//class DataFaker {
//public:
// int count;
// City *cities;
//
// DataFaker(int count) {
// this->count = count;
// this->cities = new City[count];
// }
//
// City* fillData() {
// for (int i = 0; i < this->count; i++) {
// this->cities[i] = {this->count};
// this->cities[i].coordinate = new Coordinate(rand() / 1000000, rand() / 1000000);
// this->cities[i].index = i;
// }
// return this->cities;
// }
//};
int main() {
// int count = 30;
//
// DataFaker *dataFaker;
// City *cities;
// Calculator *calculator;
//
// dataFaker = new DataFaker(count);
// cities = dataFaker->fillData();
// calculator = new Calculator(count);
//
// calculator->CalculateLength(cities);
// Coordinate *coordinates = new Coordinate[3];
// City *cities = new City[3];
//
// coordinates[0].x = 11;
// coordinates[0].y = 11;
//
// coordinates[1].x = 22;
// coordinates[1].y = 22;
//
// coordinates[2].x = 33;
// coordinates[2].y = 33;
//
// cities[0].coordinate = &coordinates[0];
// cities[1].coordinate = &coordinates[1];
// cities[2].coordinate = &coordinates[2];
//
// CoordinateCalculator *calc = new CoordinateCalculator(cities, 3);
int cityCount = 10;
DataFaker *faker = new DataFaker;
faker->generateCities(cityCount);
CoordinateCalculator *calculator = new CoordinateCalculator(faker->cities, cityCount);
calculator->searchNextCity();
//
for (int i = 0; i < cityCount; i++) {
cout << faker->cities[i].nextCityIndex << endl;
}
}