#include<stdio.h>
#include<math.h>
int main()
{
double x, y, sum;//x作为自变量,y作为分式,sum作为最终结果
double numerator, denominator;//定义分子和分母
int factorial, i;
for (x = 0.5; x <= 3.0;)
{
factorial = 1;
sum = 0;
for (i = 1; i <= 10; i++)
{
numerator = pow(x, 2 * i - 1);
denominator = (2 * i - 1) * factorial;
y = numerator / denominator;
sum += y;
factorial = factorial * i;
}
printf("当x=%.1f,级数和为sum=%f\n", x, sum);
if (x == 0.5)
x += 0.5;
else
x += 1.0;
}
return 0;
}
【C语言编程题】第六章第四题(朱鸣华版)
最新推荐文章于 2024-08-24 21:53:36 发布