[ Eddie's Blog ]

Thursday, December 14, 2017

C++ Linear Equation: Solve for x and y

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    double a1, b1, c1, a2, b2, c2;
    cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;

    double y = (c2*a1 - a2*c1)/(a1*b2 - a2*b1);
    double x = (c1 - b1*y)/a1;


    cout << "x: " << x << endl;
    cout << "y: " << y << endl;

}
Posted by evilmind5 at 5:00 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

About Me

My photo
evilmind5
View my complete profile

Blog Archive

  • ►  2022 (2)
    • ►  Jan (2)
  • ►  2019 (6)
    • ►  Jun (1)
    • ►  Apr (2)
    • ►  Mar (3)
  • ►  2018 (4)
    • ►  Jun (2)
    • ►  Jan (2)
  • ▼  2017 (16)
    • ▼  Dec (14)
      • Write a program that reads in a sequence of number...
      • Write a program that reads in a number n. Then it ...
      • C++ Random Generator: Heads or Tails (rand)
      • C++ Calling a Function (void): 2 Coordinates of Tw...
      • C++ Drawing Patterns with Nested for Loops
      • C++ Hollow Rectangle
      • C++ Math Library Function Table
      • C++ Fahrenheit into Celsius & Celsius to Fahrenhei...
      • C++ Salesperson Salary Ranges - Write a program (u...
      • C++ Quadratic Equation
      • C++ Linear Equation: Solve for x and y
      • C++ 5-Digit Integer Split Into 5
      • C++ Number of loops, Smallest and Biggest number w...
      • C++ Without using operators (/, *, %) and only usi...
    • ►  Aug (1)
    • ►  Jul (1)
Picture Window theme. Powered by Blogger.