aboutsummaryrefslogtreecommitdiff
path: root/res/trinome.tpc
blob: c3e2f9485b82464cc2c433ed6dcc3e9ad2c2f2f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* #include <stdio.h>
   #include <math.h> */
/* int trinome(float a, float b, float c) ;
    double valeur(double a, double b, double c, double x) ; */
/* Résolution d'une équation du deuxième degré */
float r1, r2;

int main(void) {
   int b, c;
   b=-1;
   while (b<=1) {
       c=-1;
       while (c<=1) {
           print(b, c);
           if (trinome(1,b,c)) {
               print(r1, r2);
               print(valeur(1,b,c,r1),valeur(1,b,c,r2));
               if (0<=r1 && r1<=max && 0>=r2 && r2>=-max)
                   return 0;
           }
           c=c+1;
       }
       b=b+1;
   }
   return 0;
}

int trinome(float a,float b, float c) {
    float d;
    float s;
    d=b*b-4*a*c;
    if (d>=0) {
        s=sqrt(d);
        r1=(-b+s)/(2*a);
        r2=(-b-s)/(2*a);
        return 1;
    }
    return 0;
}

double valeur(double a, double b, double c, double x) {
    return a*x*x+b*x+c;
}