aboutsummaryrefslogtreecommitdiff
path: root/res/trinome.tpc
diff options
context:
space:
mode:
authorAdam NAILI2018-02-23 22:03:52 +0100
committerAdam NAILI2018-02-23 22:03:52 +0100
commit4d52709e24e05d3f2e1ea449b4a4203604b41aec (patch)
tree24da9272cdae9e5777e3b27bc3113cafec8bebfc /res/trinome.tpc
parentde916ff97b1a15f7188295cb084058dc5e8054c1 (diff)
parentf83fee146e1159344ee30711652b0ae6ebf07a5d (diff)
downloadtpc-compiler-4d52709e24e05d3f2e1ea449b4a4203604b41aec.tar.gz
Merge branch 'master' of https://github.com/pacien/upem-compil-tpc
Diffstat (limited to 'res/trinome.tpc')
-rw-r--r--res/trinome.tpc43
1 files changed, 0 insertions, 43 deletions
diff --git a/res/trinome.tpc b/res/trinome.tpc
deleted file mode 100644
index c3e2f94..0000000
--- a/res/trinome.tpc
+++ /dev/null
@@ -1,43 +0,0 @@
1/* #include <stdio.h>
2 #include <math.h> */
3/* int trinome(float a, float b, float c) ;
4 double valeur(double a, double b, double c, double x) ; */
5/* Résolution d'une équation du deuxième degré */
6float r1, r2;
7
8int main(void) {
9 int b, c;
10 b=-1;
11 while (b<=1) {
12 c=-1;
13 while (c<=1) {
14 print(b, c);
15 if (trinome(1,b,c)) {
16 print(r1, r2);
17 print(valeur(1,b,c,r1),valeur(1,b,c,r2));
18 if (0<=r1 && r1<=max && 0>=r2 && r2>=-max)
19 return 0;
20 }
21 c=c+1;
22 }
23 b=b+1;
24 }
25 return 0;
26}
27
28int trinome(float a,float b, float c) {
29 float d;
30 float s;
31 d=b*b-4*a*c;
32 if (d>=0) {
33 s=sqrt(d);
34 r1=(-b+s)/(2*a);
35 r2=(-b-s)/(2*a);
36 return 1;
37 }
38 return 0;
39}
40
41double valeur(double a, double b, double c, double x) {
42 return a*x*x+b*x+c;
43} \ No newline at end of file