Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <stdlib.h>
- #include <math.h>
- using namespace std;
- int main(){
- int a, b, c, d;
- cout << "Podaj a: ";
- cin >> a;
- if(a == 0){
- cout << "Blad, a musi byc rozne od zera (gdy a=0 bedzie to funkcja liniowa a nie kwadratowa)" << endl;
- return 0;
- }
- cout << "Podaj b: ";
- cin >> b;
- cout << "Podaj c: ";
- cin >> c;
- d = b*b-4*a*c;
- if(d == 0){
- cout << "delta = 0, jedno miejsce zerowe:" << endl;
- float x = (-b)/(2*a);
- cout << "x = " << x;
- } else if(d > 0){
- cout << "delta > 0, dwa miejsca zerowe:" << endl;
- float x1, x2;
- x1 = (-b-sqrt(d))/(2*a);
- x2 = (-b+sqrt(d))/(2*a);
- cout << "x1 = " << x1 << endl;
- cout << "x2 = " << x2 << endl;
- } else if(d < 0) {
- cout << "delta < 0, brak miejsc zerowych:" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement