Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <iomanip>
- using namespace std;
- struct tchk {
- int x,y;
- };
- int main()
- {
- tchk t1,t2,t3,t4;
- int a1,b1,c1,a2,b2,c2;
- cin >> t1.x >> t1.y >> t2.x >> t2.y;
- cin >> t3.x >> t3.y >> t4.x >> t4.y;
- a1=t2.y-t1.y;
- b1=t1.x-t2.x;
- c1=t1.y*t2.x-t2.y*t1.x;
- a2=t4.y-t3.y;
- b2=t3.x-t4.x;
- c2=t3.y*t4.x-t4.y*t3.x;
- if (a1*b2==a2*b1 && a1*c2==a2*c1 && b1*c2==b2*c1) {
- cout << 2;
- return 0;
- } else if (a1*b2!=a2*b1) {
- double x,y;
- x=double((b1*c2)-(b2*c1))/double((a1*b2)-(a2*b1));
- y=double((a2*c1)-(a1*c2))/double((a1*b2)-(a2*b1));
- cout << 1 << endl;
- cout << setprecision(9) << fixed;
- cout << x << " " << y;
- } else {
- cout << 0;
- }
- /*
- else if (a1*b2==a2*b1 && a1*c2!=a2*c1 && b1*c2!=b2*c1) {
- cout << 0;
- return 0;
- } else {
- double x,y;
- x=double((b1*c2)-(b2*c1))/double((a1*b2)-(a2*b1));
- y=double((a2*c1)-(a1*c2))/double((a1*b2)-(a2*b1));
- cout << 1 << endl;
- cout << setprecision(9) << fixed;
- cout << x << " " << y;
- }
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement