Viết Chương Trình Giải Phương Trình Bậc 2: Ax^2 + Bx +c =0 · GitHub

Skip to content Search Gists Search Gists All gists Back to GitHub Sign in Sign up Sign in Sign up Dismiss alert {{ message }}

Instantly share code, notes, and snippets.

@TheHeroTheWorldNeeds TheHeroTheWorldNeeds/assignment5.cpp Last active November 13, 2018 17:23 Show Gist options
  • Star (0) You must be signed in to star a gist
  • Fork (0) You must be signed in to fork a gist
  • Embed Select an option
    • Embed Embed this gist in your website.
    • Share Copy sharable link for this gist.
    • Clone via HTTPS Clone using the web URL.

    No results found

    Learn more about clone URLs Clone this repository at <script src="https://gist.github.com/TheHeroTheWorldNeeds/a74caaa9db02884f18a42d6675edab68.js"></script>
  • Save TheHeroTheWorldNeeds/a74caaa9db02884f18a42d6675edab68 to your computer and use it in GitHub Desktop.
Code Revisions 2 Embed Select an option
  • Embed Embed this gist in your website.
  • Share Copy sharable link for this gist.
  • Clone via HTTPS Clone using the web URL.

No results found

Learn more about clone URLs Clone this repository at <script src="https://gist.github.com/TheHeroTheWorldNeeds/a74caaa9db02884f18a42d6675edab68.js"></script> Save TheHeroTheWorldNeeds/a74caaa9db02884f18a42d6675edab68 to your computer and use it in GitHub Desktop. Download ZIP Viết chương trình giải phương trình bậc 2: ax^2 + bx +c =0 Raw assignment5.cpp This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters
#include <iostream>
using namespace std;
#include <math.h>
int main()
{
float a, b, c;
cout << "\t\t------- PHUONG TRINH BAC II: ax^2 + bx + c = 0 -------";
cout << "\nEnter a: ";
cin >> a;
cout << "\nEnter b: ";
cin >> b;
cout << "\nEnter c: ";
cin >> c;
cout << "\nGiai phuong trinh bac II : " << a << "x^2 + " << b << "x + " << c << " = 0" << endl;
if (a == 0)
{
if (b == 0)
{
if (c == 0)
{
cout << "Phuong trinh vo so nghiem";
}
else
{
cout << "Phuong trinh vo nghiem";
}
}
else
{
cout << "Tro ve giai phuong trinh bac I: " << b << "x + " << c << " = 0";
cout << "\n\tNghiem cua pt x = " << (float)-c/b << endl;
}
}
else
{
float x1, x2;
float Delta = (b * b) - (4 * a * c);
if (Delta < 0)
{
cout << "Phuong trinh vo nghiem";
}
else if (Delta == 0)
{
cout << "Phuong trinh co no kep x = " << (float)-b / (2 * a);
}
else
{
cout << "Phuong trinh co 2 nghiem phan biet: ";
x1 = (-b + sqrt(Delta)) / (2 * a);
x2 = (-b - sqrt(Delta)) / (2 * a);
cout << "\n\t\tx1 = " << x1;
cout << "\n\t\tx2 = " << x2;
}
}
cout << endl;
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment You can’t perform that action at this time.

Từ khóa » Viết Phương Trình Giải Phương Trình Bậc 2 Ax^2+bx+c=0