Odpowiedź:
#include <iostream>
#include <cmath>
using namespace std;
float f(float x) {
return pow(x, 2) - (3*x) + 5;
}
int main() {
int n = 20;
int a = 0;
int b = 4;
float x = (float)b / (float)n;
float sr = x / 2;
float y[n];
for (int i = 0; i < n; i++) {
float arg = sr + (i*x);
y[i] = f(arg);
}
float suma = 0;
for (int i = 0; i < n; i++) {
suma += x*y[i];
}
cout << "Pole: " << suma;
}
Wyjaśnienie: