Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- int main(int argc, char *argv[]) {
- double a,b,c,x1,x2,x,delta,spr1,spr2;
- int k;
- while(1)
- {
- do
- {
- printf("\n POdaj a");
- k=scanf("%lf",&a);
- if(k==0) printf("\n Blad formatu");
- fflush(stdin);
- }
- while(k==0);
- do
- {
- printf("\n POdaj b");
- k=scanf("%lf",&b);
- if(k==0) printf("\n Blad formatu");
- fflush(stdin);
- }
- while(k==0);
- do
- {
- printf("\n POdaj c");
- k=scanf("%lf",&c);
- if(k==0) printf("\n Blad formatu");
- fflush(stdin);
- }
- while(k==0);
- if(a==0)
- {
- if(b==0&&c==0)printf("\n Tozsamosc");
- if(b==0&&c!=0) printf("\n Sprzecznosc");
- if(b!=0&&c!=0) printf("\n Rownanie liniowe");
- {
- x=-b/c;
- printf("\n Rownanie liniowe wynosi %f",x);
- }
- }
- if(a!=0)
- {
- delta=b*b-(4*a*c);
- printf("\n delta wynosi %f",delta);
- if(delta==0);
- {
- printf("\n Pierwiastek podwojny");
- x=-b/(2*a);
- printf("\n Wynosi %f",x);
- }
- if(delta>0)
- {
- printf("\n Dwa pierwiastki");
- x1=(-b+sqrt(delta))/(2*a);
- x2=(-b-sqrt(delta))/(2*a);
- printf("\n x1=%f, x2=%f",x1,x2);
- spr1=a*x1*x1+b*x1+c;
- spr2=a*x2*x2+b*x2+c;
- printf("sprawdzenia %f i %f",spr1,spr2);
- }
- if(delta<0)
- {
- printf("\n masz przerabane");
- }
- }
- getch();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement