当前位置:网站首页>Zzuli:1041 sum of sequence 2
Zzuli:1041 sum of sequence 2
2022-07-03 14:33:00 【Snake_____】
Title Description
Enter an integer n, Output sequence 1-1/3+1/5-…… front n Sum of items .
Input
Enter only one integer n.
Output
The result is reserved 2 Is a decimal , Take a line alone .
The sample input Copy
3
Sample output Copy
0.87
#include <stdio.h>
int main()
{
int n,i,sign=1;
double t,term,sum=1,deno=3;
scanf("%d",&n);
if(n!=0)
{
for(i=1;i<n;i++)
{
t=1/deno;
sign=(-1)*sign;
term=sign*t;
deno=deno+2;
sum=sum+term;
}
printf("%.2lf",sum);}
else
printf("0.00");
return 0;
}边栏推荐
- Table of mathematical constants by q779
- Some concepts about agile
- Leetcode(4)——尋找兩個正序數組的中比特數
- tonybot 人形机器人 红外遥控玩法 0630
- Find books ()
- Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue
- Analysis of gene family characteristics - chromosome location analysis
- 数学常数表 by q779
- NPM install is stuck with various strange errors of node NPY
- 表单文本框的使用(一) 选择文本
猜你喜欢

天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪

7-18 finding the single root of polynomial by dichotomy
![洛谷P5018 [NOIP2018 普及组] 对称二叉树 题解](/img/89/da1a3a38e02671628f385de0f30369.png)
洛谷P5018 [NOIP2018 普及组] 对称二叉树 题解

Leetcode(4)——尋找兩個正序數組的中比特數
![[qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?](/img/f6/fe61c84f289f0e74a45946dac687a6.jpg)
[qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?

tonybot 人形机器人 首次开机 0630

retrofit

Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue

使用并行可微模拟加速策略学习

Tailing rushes to the scientific and Technological Innovation Board: it plans to raise 1.3 billion, and Xiaomi Changjiang is the shareholder
随机推荐
Tonybot Humanoïde Robot Infrared Remote play 0630
String reverse order
China PETG market forecast and Strategic Research Report (2022 Edition)
6-9 statistics of single digits (15 points)
Why is this error reported when modifying records in the database
Solr series of full-text search engines - basic principles of full-text search
adc128s022 ADC verilog设计实现
Luogu p3065 [usaco12dec]first! G problem solution
npm install卡住与node-npy的各种奇怪报错
Analysis of gene family characteristics - chromosome location analysis
中国锂电池电解液行业市场专项调研报告(2022版)
Sword finger offer 28 Symmetric binary tree
超简单手机地图开发
修改数据库中的记录为什么报这个错
Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值
Zabbix添加Calculated items后保存页面成空白
JVM garbage collector
7-4 BCD decryption (10 points)
Timecho of Tianmou technology completed an angel round financing of nearly 100 million yuan to create a native timing database of the industrial Internet of things
Luogu p4047 [jsoi2010] tribal division solution