#include #include #include using namespace std; class RownanieKwadratowe { public: float a; float b; float c; void wczytaj(); void rozwiaz(); }; void RownanieKwadratowe::wczytaj() { cout << "Podaj wspolczynniki rownania kwadratowego: \n"; cout << "a = "; cin >> a; cout << "b = "; cin >> b; cout << "c = "; cin >> c; } void RownanieKwadratowe::rozwiaz() { float delta,x1,x2; delta = b*b-4*a*c; if (delta > 0) { x1 = (-b-sqrt(delta))/(2*a); x2 = (-b+sqrt(delta))/(2*a); cout << "Istnieja dwa rozwiazania: " << x1 << ", " << x2 << "\n"; } if (delta == 0) { x1 = -b/(2*a); cout << "Istnieje jedno rozwiazanie: " << x1 << "\n"; } if (delta < 0) cout << "Brak rozwiazania.\n"; } int main(int argc, char *argv[]) { RownanieKwadratowe rownanie; rownanie.wczytaj(); rownanie.rozwiaz(); system("PAUSE"); return EXIT_SUCCESS; }