#include #include #include float factorial(float n) { float res=1; for(float i=1;i<=n;i++) res*=i; return res; } int main() { setlocale(0, ""); float Y=0; printf("%s %17s %14s %11s","x","Y","S","N"); fflush(stdout); for(float x=0;x<=1;x+=0.2){ float S=0; Y =cos(1-x*4); float delta=1; int n=0; while(delta>0.000001) { S += pow(-1, n) * pow(1 - x * 4, 2 * n) / factorial(2 * n); n++; delta = fabs(S - Y); }printf("\n%f %14.6f %14.6f %d", x, Y, S, n); } return 0; }