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
| // programme principal
int a,b,n=100;
double x;
double(*p_creneau)(int x);
p_creneau=creneau ;
a = p_creneau(6);
printf("%f\n",p_creneau(6));
int A = rectangle(p_creneau,0,6,n);
printf("rectangle = %d ", A );
//fonctions
/* création de la fonction créneau*/
double creneau (int x)
{
x=6;
return x;
}
/*fonction pour integrer avec la méthode rectangle*/
double rectangle ( double (*f)(), int a, int b, int n)
{
int i=0,A=0;
float test;
for(i=0;i<n;i++)
{test=(b-a)/n;
A=A+ test;
printf("%d \n",test);
A=A + f(a+i*(b-a)/n);}
return A; |
Partager