SHARE
TWEET

Untitled

a guest Sep 18th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     double a1, b1, c1;
  10.     double a2, b2, c2;
  11.  
  12.     cout << "input a1: ";
  13.     cin >> a1;
  14.     cout << "input b1: ";
  15.     cin >> b1;
  16.     cout << "input c1: ";
  17.     cin >> c1;
  18.     cout << "input a2: ";
  19.     cin >> a2;
  20.     cout << "input b2: ";
  21.     cin >> b2;
  22.     cout << "input c2: ";
  23.     cin >> c2;
  24.  
  25.  
  26.     double x, y;
  27.  
  28.     if (((a1 != 0) || (b1 != 0)) && ((a2 != 0) || (b2 != 0))) {
  29.         if ((a1 == a2) && (b1 == b2) && (c1 == c2))
  30.             cout << "lines coincide" << endl;
  31.  
  32.         else if ((a1 == a2) && (b1 == b2) && (c1 != c2))
  33.             cout << "lines don't overlap" << endl;
  34.  
  35.         else {
  36.             y = (c2 - (a2 * c1 / a1)) / ((((-(a2)) * c1) / a1) + b2);
  37.             x = (c1 - b1 * y) / a1;
  38.             cout << "lines ovelap: ";
  39.             cout << "x = " << x << ", y = " << y << endl;
  40.         }
  41.     }
  42.     else if (((a1 == 0) && (b1 == 0)) && ((a2 != 0) || (b2 != 0)))
  43.         cout << "first line doesn't exist" << endl;
  44.  
  45.     else if (((a2 != 0) || (b2 != 0)) && ((a1 == 0) && (b1 == 0)))
  46.         cout << "second line doesn't exist" << endl;
  47.  
  48.     else if ((a2 == 0) && (b2 == 0) && (a1 == 0) && (b1 == 0))
  49.         cout << "both lines don't exist" << endl;
  50.     else cout << "wrong input" <<
  51.  
  52.     system("pause");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top