#include <stdio.h> #include <math.h>

int main() { int n = 1; double term = 1.0 / (1.0 + n * n); double sum = term; while (term >= pow(10, -6)) { n++; term = 1.0 / (n * n + 1); sum += term; } printf("The sum is %.6f\n", sum); return 0; }

设计算法并编写程序计算11^2+1+12^2+1+13^2+1+14^2+1+…+1n^2+1直到最后项小于10^-6。使用c语言for循环语句

原文地址: https://www.cveoy.top/t/topic/dwvj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录