Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc
- clear
- disp 'Laboratorium 2'
- disp 'Program sluzy do oblicznania rownania kwadratowego lub liniowego'
- disp 'ax^2+bx+c=0'
- format short
- a=input ('Podaj liczbe a=');
- b=input ('Podaj liczbe b=');
- c=input ('Podaj liczbe c=');
- d=b^2-4*a*c
- p=sqrt(d);
- if a==0 & b==0 & c==0
- disp 'rownanie jest tozsamosciowe'
- elseif a==0 & b==0 & c~=0
- disp 'rownanie jest sprzeczne'
- elseif a==0 & b~=0
- disp 'jest to równanie liniowe o jednym pierwiastku'
- x=(-b)/a
- elseif a~=0
- disp 'rownanie kwadratowe'
- if d<0
- disp 'brak pierwiastków'
- elseif d==0
- disp 'wystepuje jeden pierwiastek'
- x=-b/(2*a)
- else
- disp 'wystepuja dwa pierwiastki'
- x1=((-b)-(p))/2*a
- x2=((-b)+(p))/2*a
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement