Skip to content

Instantly share code, notes, and snippets.

@Hajto
Created November 5, 2016 17:38
Show Gist options
  • Save Hajto/a37ad999ef5309aff7c5627df7319bfb to your computer and use it in GitHub Desktop.
Save Hajto/a37ad999ef5309aff7c5627df7319bfb to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<math.h>
int main() {
//Serio kurwa? Wiesz ze nie musisz uzywać jednoliterowych zmiennych? Wiesz ze mozesz napisac x_1, albo pierwszy_pierwiastek?
double a, b, c, d, x, z, p, q;
do {
printf("Podaj wartosc a: \n ");
scanf("%lf", & a);
printf("Podaj wartosc b: \n");
scanf("%lf", & b);
printf("Podaj wartosc c: \n");
scanf("%lf", & c);
printf("----------------------------------------\n");
d = (b * b - (4 * a * c));
x = ((-c) / b);
if (a == 0)
if (b == 0)
if (c == 0) printf("");
else printf("sprzecznosc \n");
else printf("x= %lf \n", x);
else {
if (d < 0) printf("Funkcja nie ma miejsc zerowych \n");
else
if (d == 0) {
x = (-b) / (2 * a);
printf("Miejscem zerowym jest : %lf", x);
} else {
p = (-b) / (2 * a);
q = sqrt(d) / (2 * a);
x = p - q;
z = p + q;
printf("Pierwiastki wynosza : %lf i %lf ", x, z);
}
}
} while(a != 0 || b != 0 || c != 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment