#include <stdio.h>
float polyn(float a[], int n, float x) {
float acc = a[n - 1];
for (int i = n - 1; i >= 1; i--)
acc = acc * x + a[n - 1];
return acc;
}
int main(void) {
float coeffs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 };
printf("%f\n", polyn
(coeffs
, 9, 1)); printf("%f\n", polyn
(coeffs
, 9, 2)); printf("%f\n", polyn
(coeffs
, 9, 3)); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgpmbG9hdCBwb2x5bihmbG9hdCBhW10sIGludCBuLCBmbG9hdCB4KSB7CglmbG9hdCBhY2MgPSBhW24gLSAxXTsKCWZvciAoaW50IGkgPSBuIC0gMTsgaSA+PSAxOyBpLS0pCgkJYWNjID0gYWNjICogeCArIGFbbiAtIDFdOwoJcmV0dXJuIGFjYzsKfQoKaW50IG1haW4odm9pZCkgewoJZmxvYXQgY29lZmZzW10gPSB7IDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEsIDEgfTsKCXByaW50ZigiJWZcbiIsIHBvbHluKGNvZWZmcywgOSwgMSkpOwoJcHJpbnRmKCIlZlxuIiwgcG9seW4oY29lZmZzLCA5LCAyKSk7CglwcmludGYoIiVmXG4iLCBwb2x5bihjb2VmZnMsIDksIDMpKTsKCXJldHVybiAwOwp9Cg==