一、N-S流程图;
二、运行结果;
三、源代码;
# define _CRT_SECURE_NO_WARNINGS
# include <stdio.h>
# include <math.h>int main()
{//初始化变量值;int symbol = 1;double denominator = 1.0, sum = 0, term = 1.0;//循环判断;while (fabs(term) >= 1e-6){//运算;sum = sum + term;//改变变量的值;symbol = -symbol;denominator = denominator + 2;term = symbol / denominator;}//运算;sum = sum * 4;//输出结果;printf("π的近似值为:%10.8f\n", sum);return 0;
}