We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Its just mid-point formula .
[(x_1 + x_2)/2 , (y_1 + y_2)/2]
but instead of finding mid point we have find x2 and y2
import java.io.;
import java.util.;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner scan = new Scanner(System.in);
int test_case = scan.nextInt();
for(int i=0;i<test_case;i++){
int x1 = scan.nextInt();
int y1 = scan.nextInt();
int x2 = scan.nextInt();
int y2 = scan.nextInt();
findNextPoint(x1,x2,y1,y2);
}
}
private static void findNextPoint(int x1, int x2, int y1, int y2) {
// TODO Auto-generated method stub
int x, y;
x= 2*x2 - x1;
y = 2*y2 - y1;
System.out.println(x +" "+y);
}
Find the Point
You are viewing a single comment's thread. Return to all comments →
Its just mid-point formula . [(x_1 + x_2)/2 , (y_1 + y_2)/2]
but instead of finding mid point we have find x2 and y2
import java.io.; import java.util.;
public class Solution {
}