Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float Rectangle(float a, float b, int n)
- {
- float res = 0;
- for(int k=0;k<n;k++)
- {
- res = res + 1/(a + k*((b-a)/n));
- }
- res = res * ((b-a)/n);
- return res;
- }
- float Milieu(float a, float b, int n)
- {
- float res =0;
- for(int k=0;k<n;k++)
- {
- res = res + 1/(a + (2*k +1) * ((b-a)/(2*n)));
- }
- res = res * ((b-a)/n);
- return res;
- }
- float erreurRectangle(float a, float b, int n)
- {
- }
- int main()
- {
- float a = 1.0;
- float b = 2.0;
- int n = 1;
- while(Milieu(a,b,n) < log(2))
- {
- n++;
- }
- float res = Milieu(a,b,n);
- printf("Res = %f \n", res);
- printf("n = %d",n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement