#include #include #include int main() { const float coeff[] = {.1, .1, .09, .09, .08, .06, .05, .04, .02, .01, 0, -.01, -.02, -.02, -.02, -.02, -.02, -.02, -.01, -.01, 0, 0, .01, .01, .01, .01, .01, .01, .01, 1}; //Jednicka je zarazka! size_t coefs = 0; while (coeff[++coefs] < 1); //Pocet koeficientu float history[coefs]; bzero(&history, coefs * sizeof(float)); //Vynulovani float x; while (scanf("%f", &x) != EOF) { //printf("%f\n", x); //Posun prvku v poli for (size_t i = coefs; i > 0; i--) { history[i] = history[i - 1]; } history[0] = x; //printa(history, coefs); //FIR float out = 0; for (size_t i = 0; i < coefs; i++) { out += history[i] * coeff[i]; } printf("%f\n", out); } return EXIT_SUCCESS; }