Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "stdlib.h"
- #include <iostream>
- #include <math.h>
- using namespace std;
- #define COEFICIENTI 3
- void Culoare_Consola();
- float Delta_Ecuatie(float v[]);
- float v[COEFICIENTI], delta, x1, x2;
- int main() {
- char repeta;
- Culoare_Consola();
- do {
- cout << endl;
- cout << " Introduceti coeficientii: " << endl;
- for (int i = 1; i <= COEFICIENTI; i++) {
- if (i == 1) {
- cout << "a="; cin >> v[i];
- }
- else if (i == 2) {
- cout << "b="; cin >> v[i];
- }
- else if (i == 3) {
- cout << "c="; cin >> v[i];
- }
- }
- delta = Delta_Ecuatie(v);
- cout << endl;
- if (delta < 0) {
- cout << " (!)(!) Ecuatia nu are radacini reale! \n";
- }
- else if (delta == 0) {
- cout << " (!) X1 = X2: \n";
- x1 = -v[2] / 2 * v[1];
- x1 = x2;
- cout << " x1 = x2 = " << x1 << endl;
- }
- else if (delta > 0) {
- cout << " (!) Ecuatia are doua solutii reale! \n";
- x1 = (-v[2] + sqrt(delta)) / 2 * v[1];
- x2 = (-v[2] - sqrt(delta)) / 2 * v[1];
- cout << " x1 = " << x1 << ", x2 = " << x2 << endl;
- }
- cout << " Mai vrei odata? (D/N) "; cin >> repeta;
- } while (repeta == 'D' || repeta == 'd');
- system("pause");
- return 0;
- }
- float Delta_Ecuatie(float v[]) {
- float delta;
- delta = v[2] * v[2] - 4 * v[1] * v[3];
- return delta;
- }
- void Culoare_Consola() {
- system("COLOR 03");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement