-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproject2_extra_functions.c
More file actions
43 lines (40 loc) · 1.63 KB
/
project2_extra_functions.c
File metadata and controls
43 lines (40 loc) · 1.63 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
//OPTIONAL function wich checks if a point (xtemp,ytemp) doesn't have any other
//points in a circle of radius 100 around it AFTER the vectors x,y are fully
//created (it skips the point (xtemp,ytemp) while iterating on vectors x,y).
int checkdistances2(long int *x, long int *y, long int xtemp, long int ytemp, int vectorsize) {
for (int i = 0; i < vectorsize; i++) {
if (x[i] == -1) {
break;
}
if (calcdistance(xtemp, x[i], ytemp, y[i]) > 100 || (x[i] == xtemp && y[i] == ytemp)) {
continue;
}
else {
return 0;
}
}
return 1;
}
//prints the coordinates stored in the same line of two vectors x,y with the
//same length 'size' to the command prompt (for testing purposes)
void printcoords(long int *x, long int *y, int size) {
for (int i = 0; i < size; i++) {
printf("Coords of point %d are (%li,%li)\n", i, x[i], y[i]);
}
}
//Prints all the connections of airport with x,y vector index 'airportindex'
//For testing purposes
void printconnections(long int *start, long int *destinations, long int *distance, long int *next, long int airportindex) {
long int index = start[airportindex];
do {
printf("Airport #%li connects with airport #%li and their distance is %li\n", airportindex, destinations[index], distance[index]);
index = next[index];
} while (index != -1);
}
//prints a vector with length size to the command prompt (for testing purposes)
void printvector(long int *vector, int size) {
printf("Printing Vector of size %d...\n", size);
for (int i = 0; i < size; i++) {
printf("%li\n", vector[i]);
}
}