View Code of Problem 67

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()) {
			int[] x = new int[4];
			int[] y = new int[4];
			for(int i = 0;i < 4;i++) {
				x[i] = scanner.nextInt();
				y[i] = scanner.nextInt();
			}
			if(x[0] == x[1] && x[2] == x[3] && x[0] != x[2]) {
				System.out.println("No");
			}
			else if(x[0] != x[1] && x[2] != x[3]) {
				int k1 =(y[1] - y[0]) / (x[1] - x[0]);
				int k2 =(y[3] - y[2]) / (x[3] - x[2]);
				int b1 = y[1] - k1 * x[1];
				int b2 = y[2] - k2 * x[2];
				if(k1 == k2 && b1 != b2) {
					System.out.println("No");
				}
				else {
					System.out.println("Yes");
				}
			}
			else {
				System.out.println("Yes");
			}
		}
	}
}

Double click to view unformatted code.


Back to problem 67