Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int gyokalatt(a,b,c);
- int tortalatt(a);
- double szamitas(a,b,c,temp1,temp2);
- double szamitass(a,b,c,temp1,temp2);
- int main(void){
- int a;
- int b;
- int c;
- int temp1;
- int temp2;
- double x1;
- double x2;
- printf("a erteke: ");
- scanf("%d", &a);
- printf("b erteke: ");
- scanf("%d", &b);
- printf("c erteke: ");
- scanf("%d", &c);
- temp1=gyokalatt(a,b,c);
- temp2=tortalatt(a);
- if (temp1<0)
- {
- printf("matematikai hiba");
- return 1;
- }
- if (temp2==0)
- {
- printf("matematikai hiba");
- return 2;
- }
- printf("%d, %d, %d, %d, %d,\n", a, b, c, temp1, temp2);
- x1=szamitas(a,b,c,temp1,temp2);
- x2=szamitass(a,b,c,temp1,temp2);
- printf("Az elso megoldas %lf\n", x1);
- printf("A masodik megoldas %lf\n", x2);
- return 0;
- }
- int gyokalatt(a,b,c)
- {
- int r;
- r=pow(b,2)-(4*a*c);
- return r;
- }
- int tortalatt(a)
- {
- int n;
- n=2*a;
- return n;
- }
- double szamitas(a,b,c,temp1,temp2)
- {
- double x1;
- x1=((-b)+sqrt(temp1))/temp2;
- return x1;
- }
- double szamitass(a,b,c,temp1,temp2)
- {
- double x2;
- x2=((-b)-sqrt(temp1))/temp2;
- return x2;
- }
Advertisement
Add Comment
Please, Sign In to add comment