blob: abcbd28d2c89b20f78c870c4c1d10c4d855076e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
static double square(double x)
{
return x * x;
}
static double integr(double (*f)(double), double low, double high, int n)
{
double h, x, s;
int i;
h = (high - low) / n;
s = 0;
for (i = n, x = low; i > 0; i--, x += h) s += f(x);
return s * h;
}
double test(int n)
{
return integr(square, 0.0, 1.0, n);
}
|