Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- #include <cstdlib>
- #include <string>
- using namespace std;
- int main()
- {
- double a, b, c, delta, x1, x2;
- int wybor = 1;
- while (wybor)
- {
- system("cls");
- cout << "Program Liczy miejsca zerowe rownan kwadratowych" << endl;
- cout << "Podaj wspolczynniki a, b oraz c" << endl;
- cout << "Zamiast przecinka uzyj kropki" << endl;
- cin >> a >> b >> c;
- //cin >> b;
- //cin >> c;
- system("cls"); //czysci okienko cmd//
- if (a == 0)
- {
- if (b != 0)
- {
- cout << "to nie rownanie kwadratowe, tylko liniowe, miejsce zerowe wynosi: ";
- x1 = x2 = -c / b;
- cout << x1 << endl;
- }
- else if ((b == 0) && (c == 0))
- {
- cout << "Rownanie ma nieskoczenie wiele rozwiazan" << endl;
- }
- else
- {
- cout << "brak rozwiazan" << endl;
- }
- }
- else
- {
- delta = b * b - 4 * a*c;
- if (delta > 0)
- {
- x1 = (-b - sqrt(delta)) / 2 * a;
- x2 = (-b + sqrt(delta)) / 2 * a;
- cout << "x1=" << x1 << " x2=" << x2 << endl;
- }
- else if (delta == 0)
- {
- x1 = -b / 2 * a;
- cout << "x1=" << x1 << endl;
- }
- else
- {
- cout << "delta ujemna brak miejsc zerowych :/" << endl;
- }
- }
- cout << "chcesz jewszcze raz? [0/1]" << endl;
- do {
- cin.clear();
- cin >> wybor;
- }
- while (wybor != 1);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement