#include <stdio.h>
#include <math.h>
float s_trap_brut (float a, float b, float step){
if((a == b) || (step == 0.0))
return 0.0;
float sum = 0;
float i;
for(i = a; i < b; i += step){
sum
+= ((pow(M_E
, i
) + pow(M_E
, i
+step
)) * step
) / 2; }
return sum;
}
int main(void) {
printf("S trapez: %f", s_trap_brut
(0, 1, 0.1)); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgpmbG9hdCBzX3RyYXBfYnJ1dCAoZmxvYXQgYSwgZmxvYXQgYiwgZmxvYXQgc3RlcCl7CgkKCWlmKChhID09IGIpIHx8IChzdGVwID09IDAuMCkpCgkJcmV0dXJuIDAuMDsKCQoJZmxvYXQgc3VtID0gMDsKCWZsb2F0IGk7Cglmb3IoaSA9IGE7IGkgPCBiOyBpICs9IHN0ZXApewoJCXN1bSArPSAoKHBvdyhNX0UsIGkpICsgcG93KE1fRSwgaStzdGVwKSkgKiBzdGVwKSAvIDI7Cgl9CgkKCXJldHVybiBzdW07Cn0KCmludCBtYWluKHZvaWQpIHsKCQoJcHJpbnRmKCJTIHRyYXBlejogJWYiLCBzX3RyYXBfYnJ1dCgwLCAxLCAwLjEpKTsKCXJldHVybiAwOwp9Cg==