Skip to content

Commit c4a8ea7

Browse files
authored
Create 02_funkcja_kwadratowa.cpp
1 parent becd6ce commit c4a8ea7

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

AHE/02_funkcja_kwadratowa.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <iostream>
2+
#include <cmath>
3+
4+
using namespace std;
5+
6+
int main(int argc, char** argv) {
7+
float a, b, c; // wspolczynniki
8+
float delta, x1, x2; // delta, pierwiastki
9+
10+
cout << "Obliczanie miejsc zerowych funkcji kwadratowej" << endl;
11+
cout << "Podaj wspolczynniki: " << endl;
12+
cout << "a = "; cin >> a;
13+
cout << "b = "; cin >> b;
14+
cout << "c = "; cin >> c;
15+
16+
if (a != 0) {
17+
delta = pow(b, 2) - 4*a*c;
18+
19+
if (delta > 0) {
20+
x1 = (-b - sqrt(delta)) / 2*a;
21+
x2 = (-b + sqrt(delta)) / 2*a;
22+
23+
cout << "Istnieja 2 miejsca zerowe:" << endl;
24+
cout << "x1 = " << x1 << endl;
25+
cout << "x2 = " << x2 << endl;
26+
27+
} else if (delta == 0) {
28+
x1 = -b / 2*a;
29+
30+
cout << "Istnieje 1 miejsce zerowe:" << endl;
31+
cout << "x = " << x1 << endl;
32+
33+
} else {
34+
cout << "Brak miejsc zerowych rowniania w zbiorze liczb rzeczywistych!" << endl;
35+
}
36+
37+
//float y = a*pow(x, 2) + b*x + c; // wzor funkcji kwadratowej
38+
39+
40+
} else {
41+
cout << "Wspolczynnik a jest rowny 0, funkcja nie jest funkcja kwadratowa!" << endl;
42+
}
43+
44+
system("PAUSE");
45+
46+
47+
return 0;
48+
}

0 commit comments

Comments
 (0)