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 k1, k2;
		double b1, b2;
		if (x1 == x2) {
			k1 = numeric_limits<double>::max();
			b1 = x1;
		}
		else if (x1 != x2) {
			k1 = (y2 - y1) / (x2 - x1);
			b1 = y1 - k1 * x1;
		}
		if (x3 == x4) {
			k2 = numeric_limits<double>::max();
			b2 = x2;
		}
		else if (x3 != x4) {
			k2 = (y4 - y3) / (x4 - x3);
			b2 = y3 - k2 * x3;
		}

		if ((k1 == k2 && b1 == b2) || k1 != k2) {
			cout << "Yes" << endl;
		}
		else if (k1 == k2 && b1 != b2) {
			cout << "No" << endl;
		}
	}
}
/*
Main.cc: In function 'int main()':
Main.cc:11:9: error: 'numeric_limits' was not declared in this scope
    k1 = numeric_limits<double>::max();
         ^~~~~~~~~~~~~~
Main.cc:11:24: error: expected primary-expression before 'double'
    k1 = numeric_limits<double>::max();
                        ^~~~~~
Main.cc:19:9: error: 'numeric_limits' was not declared in this scope
    k2 = numeric_limits<double>::max();
         ^~~~~~~~~~~~~~
Main.cc:19:24: error: expected primary-expression before 'double'
    k2 = numeric_limits<double>::max();
                        ^~~~~~
*/

Double click to view unformatted code.


Back to problem 67