Bonjour,
pour mon travail je dois realiser un programme qui, a partir de certaines donnees entrees par l'utilisateur, sort le maximum d'une fonction par rapport a trois variables theta1, theta2 et X.
J'ai deja verifie que le main tout seul fonctionne, ainsi que toutes les boucles if et for, elles sont ok. Je pense que le probleme vient des trois dernieres lignes mais je ne sais pas comment faire ! J'espere avoir ete assez claire ...
Merci de votre aide !

Voilou mon petit (!) programme :

Code c : Sélectionner tout - Visualiser dans une fenêtre à part
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
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
 
/*Function declaration*/
float TMAXF (float,float,float,float,float,float,float,float,float,int,float,float);
 
/*Main function*/
int main()
{
    float qd,Hd,betad,id,fid,cd,rud,gammad,alphad, dholed,Shd,Tmaxd;
    int typed;
 
    /*Initialization*/
   dholed=0;
   Shd=0;
   Tmaxd=0;
 
    /*Input values*/
    printf("Enter q value (kN/m2)\n");
    scanf("%f",&qd);
    printf("Enter H value (m)\n");
    scanf("%f",&Hd);
    printf("Enter beta value (degrees)\n");
    scanf("%f",&betad);
    printf("Enter i value (degrees)\n");
    scanf("%f",&id);
    printf("Enter fi value (degrees)\n");
    scanf("%f",&fid);
    printf("Enter c value (kN/m2)\n");
    scanf("%f",&cd);
    printf("Enter ru value\n");
    scanf("%f",&rud);
    printf("Enter gamma value (kN/m3)\n");
    scanf("%f",&gammad); 
    printf("Enter interface sliding value (Entry 999 for a default value)\n");
    scanf("%f",&alphad);
    printf("Type of reinforcement : 1->Geotextiles/Geogrids, 2->Strip reinforcement, 3->Soil nails\n");
    scanf("%d",&typed);
    if (typed==3)
    {
                printf("Enter the diameter of the grout hole around the nail\n");
                scanf("%f",&dholed);
                printf("Enter the horizontal spacing\n");
                scanf("%f",&Shd);
    }
 
     Tmaxd=TMAXF(qd,Hd,betad,id,fid,cd,rud,gammad,alphad,typed,dholed,Shd);
     printf("Tmax=%f",Tmaxd);
 
    /*Wait before quit*/
    system("pause");
 
}

Code c : Sélectionner tout - Visualiser dans une fenêtre à part
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 
/*TMAXF function*/
 
float TMAXF(float q,float H,float beta,float i,float fi,float c,float ru, float gamma, float alpha,int type,float dhole, float Sh)
{
 
    float Tmax, H1,L,Xlim,theta1,theta2,X,Tmax1,Y,a,b,k,d,e,f,g,s,t,j,m,u,v,w,z,lambdas,W1,W2,U1,U2,K1,K2;
    X=0;
    Tmax=0;
    Tmax1=0;
 
    /*alpha default values*/
    if (alpha==999)
    {
       switch (type)
       {
       case 1:
       alpha=0.85;
       break;
       case 2:
       alpha=0.9;
       break;
       case 3:
       alpha=0.9;
       break;
       }
    }
 
    /*H1=Height with surcharge*/
    H1=H+(q/gamma);
    /*L=length from the toe to the crest*/
    L=H1/tan(beta*M_PI/180);
   /*Imposed limit value for X*/  
    Xlim=2.5*H1;   
 
    for (theta1=0;theta1<=90;theta1=theta1+0.1)
    {
        for (theta2=0;theta2<=90;theta2=theta2+0.1)
        {
            for (X=0;X<Xlim;X=X+0.1)
            {
                Y=X*tan(theta1*M_PI/180);
                a=(H1-X*tan(beta*M_PI/180));
                b=(H1-Y-a);
                k=((a+b)/tan(theta1*M_PI/180))-a/tan(beta*M_PI/180);
                d=k*tan(theta1*M_PI/180);
                e=k/cos(theta1*M_PI/180);
                f=((a+b)/sin(theta1*M_PI/180))-e;
                g=(a+b)/sin(theta1*M_PI/180);
                s=(a+b)/tan(theta1*M_PI/180);
                t=k-s;
                j=t*tan(theta2*M_PI/180);
                m=sqrt(X+Y);
                u=b/(tan(theta1*M_PI/180)-tan(beta*M_PI/180));
                   if (i==0)
                   v=0;                
                   else 
                   v=k/((1/tan(i*M_PI/180))-(1/tan(theta1*M_PI/180)));
                w=v/sin(theta1*M_PI/180);
                z=t*tan(i*M_PI/180);
 
                /*Different expressions of lambdas depending on the 
                reinforcement material*/
                switch (type)
                {
                case 1:
                lambdas=alpha;
                break;
                case 2:
                lambdas=alpha*b+(1-b);
                break;
                case 3:
                lambdas=(alpha*dhole/Sh)+(1-dhole/Sh);
                break;
                }
 
                if (X<=(H1/tan(beta*M_PI/180)))
                {
                   if (X+(H1-L*tan(theta1*M_PI/180))/(tan(theta2*M_PI/180)-tan(theta1*M_PI/180))<L)
                   /*CASE 3*/
                   {
                   W1=0.5*gamma*b*u;
                   W2=0.5*gamma*b*X;
                   U1=0.5*ru*gamma*b*u/cos(theta1*M_PI/180);
                   U2=0.5*ru*gamma*b*m;
                   K1=c*u/cos(theta1*M_PI/180);
                   K2=c*m;
                   }
 
 
                   else 
                   /*CASE 1*/
                   {
                   W1=0.5*gamma*((a+b)*(a+b)/tan(theta1*M_PI/180)-a*a/tan(beta*M_PI/180)+v*k);
                   W2=0.5*gamma*b*X;
                   U1=0.5*ru*gamma*(d*(e+w)+f*(d+b));
                   U2=0.5*ru*gamma*b*m;
                   K1=c*(g+w);
                   K2=c*m;
                   }
 
                }
 
 
                else
                /*CASE 2*/
                {
                W1=0.5*gamma*(H1-Y)*(H1-Y)/tan(theta1*M_PI/180)+0.5*gamma*(v*k-t*z);
                W2=0.5*gamma*(2*X*H1-X*tan(theta2*M_PI/180)-H1*H1/tan(beta*M_PI/180)+t*t*z);
                U1=0.5*ru*gamma*(g+w)*(H1-Y+z);
                U2=0.5*ru*((H1-Y)*(X+t)/cos(theta2*M_PI/180)+j*m+z*t/cos(theta2*M_PI/180));
                K1=c*(g+w);
                K2=c*m;
                }   
 
                  Tmax1=((W1*(tan(theta1*M_PI/180)-tan(fi*M_PI/180))+(U1*tan(fi*M_PI/180)-K1)/cos(theta1*M_PI/180))/(1+tan(theta1*M_PI/180)*tan(fi*M_PI/180)))+((W2*(tan(theta2*M_PI/180)-lambdas*tan(fi*M_PI/180))+lambdas*(U2*tan(fi*M_PI/180)-K2)/cos(theta2*M_PI/180))/(1+lambdas*tan(theta2*M_PI/180)*tan(fi*M_PI/180)));
 
 
                   /*Take the maximum value of Tmax*/
                   if (Tmax1>Tmax) Tmax=Tmax1;
 
                     }
 
             }
        }
        return (Tmax);
    }