Advertisement
justkiddin

He Phuong Trinh bac nhat

Dec 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. //@___justkiddin
  2. #include<bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.     int a1, b1, c1, a2, b2, c2;
  8.     float D, Dx, Dy, x, y;
  9.     cout << "a1*x + b1*y = c1" << endl;
  10.     cout << "a2*x + b2*y = c2" << endl;
  11.     cout << "Nhap a1: ";
  12.     cin >> a1;
  13.     cout << "Nhap b1: ";
  14.     cin >> b1;
  15.     cout << "Nhap c1: ";
  16.     cin >> c1;
  17.     cout << "Nhap a2: ";
  18.     cin >> a2;
  19.     cout << "Nhap b2: ";
  20.     cin >> b2;
  21.     cout << "Nhap c2: ";
  22.     cin >> c2;
  23.     D  = a1 * b2 - a2 * b1;
  24.     Dx = c1 * b2 - c2 * b1;
  25.     Dy = a1 * c2 - a2 * c1;
  26.     if (D == 0) {
  27.         if (Dx + Dy == 0)
  28.             cout << "He phuong trinh co vo so nghiem";
  29.         else
  30.             cout << "He phuong trinh vo nghiem";
  31.     }
  32.     else {
  33.         x = Dx / D;
  34.         y = Dy / D;
  35.         cout << "He phuong trinh nghiem" << endl;
  36.         cout << "x = " << x << endl;
  37.         cout << "y = " << y;
  38.     }
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement