解题思路:前几道题的代码直接用,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语言考试练习题_排列 (C++代码)浏览:644 |
C二级辅导-公约公倍 (C语言代码)浏览:1517 |
简单的a+b (C语言代码)浏览:709 |
C语言训练-大、小写问题 (C语言代码)浏览:750 |
蛇行矩阵 (C语言代码)浏览:540 |
文科生的悲哀 (C语言代码)浏览:1423 |
出圈】指针malloc版浏览:358 |
图形输出 (C语言代码)浏览:960 |
淘淘的名单 (C语言代码)浏览:1234 |
买不到的数目 (C语言代码)浏览:3099 |