View Code of Problem 67

#include<iostream>

using namespace std;

int main() {
	double x1, x2, x3, x4, y1, y2, y3, y4;
	while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4) {
		double d1, d2, d3;
		int flag = 0;
		if (x1 != x2) {
			d1 = (y2 - y1) / (x2 - x1);
		}
		else {
			++flag;
		}

		if (x3 != x4) {
			d2 = (y4 - y3) / (x4 - x3);
		}
		else {
			++flag;
		}

		if (flag == 0) {
			if (d1 != d2) {
				cout << "Yes" << endl;
			}
			else {
				double d3 = (y3 - y1) / (x3 - x1);
				if (d1 == d3) {
					cout << "Yes" << endl;
				}
				else {
					cout << "No" << endl;
				}		
			}
		}
		else if (flag == 1) {
			cout << "Yes" << endl;
		}
		else if (flag == 2) {
			cout << "No" << endl;
		}

	}
}

Double click to view unformatted code.


Back to problem 67