Question: 0 1 . 0 2 . Calculate closer distance Problem Statement 0 2 You are given a function, int Distance ( int Ax , int

01.02. Calculate closer distance Problem Statement 02 You are given a function, int Distance (int Ax, int Ay, int Bx, int By); 03. The function accepts the coordinates of truck A(Ax, Ay) and the coordinates of truck B(Bx, By), as input. The office is at location (0,0). Implement the function to determine which truck is closer to the office by comparing the square of their distances. Return the square of the distance of the truck which is closer to the office. Square of distance between two points having coordinates (x, y) and (0,0): (Distance)2=[x2+ y2] Note: No need to compute the square root of the distances of trucks A and B from the office. If both trucks are at equal distance, return square of distance of either truck. Example: Input: 125129 Output: 169 Explanation: (Distance of truck A)2=[Ax2+ Ay2]=[122+52]=(144+25)=169(Distance of truck B)2=[Bx2+ By2]=[122+92]=(144+81)=225 Since, (169<225), hence the output is 169. ample input ple Output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!