Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int kwadrat(int a,int b,int c,double *x1,double *x2){
- double delta =((b*b)-(4*a*c));
- if(b==0 || delta <0){
- return 0;
- }
- else if(delta > 0){
- double sqdelta = sqrt(delta);
- *x1= (-b-sqdelta)/(2*a);
- *x2= (-b+sqdelta)/(2*a);
- return 2;
- }else{
- *x1 = (-b)/(2*a);
- return 1;
- }
- }
- int main()
- {
- int a,b,c;
- scanf("%d %d %d",&a,&b,&c);
- double x1=0;
- double x2=0;
- int liczba = kwadrat(a,b,c,&x1,&x2);
- if(liczba == 0 ){
- printf("nie ma pierwiastkow");
- return 0;
- }else if(liczba ==1){
- printf("jeden pierwiastek: %.3lf",x1);
- }else{
- printf("liczba pierwiastkow:%d pierwiastki: %.3lf %.3lf",liczba,x1,x2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement