解题思路:前几道题的代码直接用,i从2开始,i替换为i*i,1替换-1,每次递减t的;最后输出1.0-t
注意事项:输出时是1.0-t的值
参考代码:
/* */ #include <cstdio> #include <algorithm> #include <iostream> using namespace std; int main(){ int n; cin>>n; double t=0.0; for(int i=2;i<=n;i++){ t-=-1.0/double(i*i); } printf("%.6lf",1.0-t); return 0; }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题8.7 (C++代码)浏览:845 |
整除问题 (C语言代码)浏览:930 |
点我有惊喜!你懂得!浏览:1266 |
C语言训练-计算1~N之间所有奇数之和 (C语言代码)浏览:742 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:539 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:724 |
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:550 |
数列排序 (C语言代码)浏览:857 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:501 |
C语言程序设计教程(第三版)课后习题1.6 (C++代码)浏览:907 |