Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int main()
- {
- char a = 'y';
- int i = 0, d =0 ;
- float x1 = 0, x2 = 0, x3 = 0;
- int tab[2]={0};
- do{
- printf("Podaj wspolczynniki a,b i c trojmianu kwadratowego po spacji:");
- for(i = 0;i<3;i++)
- {
- scanf("%d", &tab[i]);
- }
- d=pow(tab[1],2)-4*tab[0]*tab[2];
- if(d>0)
- {
- x1=(-tab[1]-sqrt(d))/(2*tab[0]);
- x2=(-tab[1]+sqrt(d))/(2*tab[0]);
- printf("X1: %f X2: %f", x1, x2);
- }
- else if(d==0)
- {
- x3 = (-tab[1])/(2*tab[0]);
- printf("X1 = X2 = %f", x3);
- }
- else printf("brak rozwiazan");
- printf("\nPonowic?(y,n)?:");
- scanf("%c",a);
- }while(a=='y');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement