Advertisement
Guest User

matlabG

a guest
Oct 16th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. clc
  2. clear
  3. disp 'Laboratorium 2'
  4. disp 'Program sluzy do oblicznania rownania kwadratowego lub liniowego'
  5. disp 'ax^2+bx+c=0'
  6. format short
  7. a=input ('Podaj liczbe a=');
  8. b=input ('Podaj liczbe b=');
  9. c=input ('Podaj liczbe c=');
  10. d=b^2-4*a*c
  11. p=sqrt(d);
  12. if a==0 & b==0 & c==0
  13. disp 'rownanie jest tozsamosciowe'
  14. elseif a==0 & b==0 & c~=0
  15. disp 'rownanie jest sprzeczne'
  16. elseif a==0 & b~=0
  17. disp 'jest to równanie liniowe o jednym pierwiastku'
  18. x=(-b)/a
  19. elseif a~=0
  20. disp 'rownanie kwadratowe'
  21. if d<0
  22. disp 'brak pierwiastków'
  23. elseif d==0
  24. disp 'wystepuje jeden pierwiastek'
  25. x=-b/(2*a)
  26. else
  27. disp 'wystepuja dwa pierwiastki'
  28. x1=((-b)-(p))/2*a
  29. x2=((-b)+(p))/2*a
  30. end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement