Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main() {
- float a, b, c, delta, x1, x2;
- cout << "Podaj a: "; cin >> a;
- if(a==0) cout << "Równanie nie jest kwadratowe\n";
- else
- {
- cout << "Podaj b: "; cin >> b;
- cout << "Podaj c: "; cin >> c;
- delta=b*b-4*a*c;
- cout << "Delta wynosi: " << delta << endl;
- }
- if(delta>0) {
- x1=(-b-sqrt(delta))/(2*a);
- x2=(-b+sqrt(delta))/(2*a);
- cout << "Pierwszy pierwiastek wynosi: " << x1 << endl;
- cout << "Drugi pierwiastek wynosi: " << x2 << endl;
- }
- else if (delta==0) {
- x1=-b/(2*a);
- cout << "Pierwiastek podwójny wynosi: " << x1 << endl;
- }
- else if (delta<0) {
- cout << "Równanie nie ma pierwiastków\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement