1
I’m trying to solve a minimal tree-generating problem, where I try to find the minimum way to connect all of us. The nodes represent objects with position defined by x, y (integer numbers) in space, so I find the distance between one and the other through the following passage:
dist = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))
As I mentioned above, x
and y
are integers and the end result should be a double
with the sum of the path that travels the shortest distance to join us all.
What is happening is that my results are always giving similar values, however, not exact to what the system requires and my answer is not accepted.
Ex:
Program output: 98.00 expected exit: 98.02
How can I improve the accuracy in the final numbers?
If not, post your full code so you can analyze it better.
– Wilker