Assuming you are tying a cable from one tree's top to the other tree's base, you can use the Pythagorean Theorem:
Distance between the trees is one leg of a right triangle, height of first tree is the other. So:
a = 18 ft.
b = 25 ft.
c = Unknown hypotenuse, and necessary cable length
c2 = a2 + b2
c2 = 182 + 252
c2 = 949
c= sqrt (949)
c = 30.8 ft.
You need 30.8 feet of cable to secure the top of one tree to bottom of the other.
I hope this helps.