当前位置:网站首页>Zzuli:1042 sum of sequence 3
Zzuli:1042 sum of sequence 3
2022-07-03 14:33:00 【Snake_____】
Title Description
seek 1-2/3+3/5-4/7+5/9-6/11+... Before n Xiang He , The result is reserved 3 Decimal place .
Input
Enter a positive integer n(n>0).
Output
Output a real number , Retain 3 Decimal place , Take a line alone .
The sample input Copy
5
Sample output Copy
0.917
#include <stdio.h>
int main()
{
int n,i,sign=1;
double t,sum=1,term,den=3,mol=2;
scanf("%d",&n);
for(i=1;i<n;i++)
{
t=mol/den;
sign=(-1)*sign;
term=sign*t;
sum=sum+term;
den=den+2;
mol=mol+1;
}
printf("%.3lf",sum);
return 0;
}边栏推荐
猜你喜欢

tonybot 人形机器人 红外遥控玩法 0630

X86 assembly language - Notes from real mode to protected mode

剑指 Offer 28. 对称的二叉树

修改数据库中的记录为什么报这个错
![Luogu p5018 [noip2018 popularization group] symmetric binary tree problem solution](/img/89/da1a3a38e02671628f385de0f30369.png)
Luogu p5018 [noip2018 popularization group] symmetric binary tree problem solution

puzzle(016.4)多米诺效应

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

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

提高效率 Or 增加成本,开发人员应如何理解结对编程?

论文分享:Generating Playful Palettes from Images
随机推荐
dllexport和dllimport
2021年区域赛ICPC沈阳站J-Luggage Lock(代码简洁)
Ultra simple mobile map development
String substitution
Find the sum of the elements of each row of the matrix
光猫超级账号密码、宽带账号密码 获取
数学常数表 by q779
556. 下一个更大元素 III : 简单构造模拟题
中国锂电池电解液行业市场专项调研报告(2022版)
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
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
Thread.sleep和TimeUnit.SECONDS.sleep的区别
SSH access control, blocking the IP when logging in repeatedly to prevent brute force cracking
如何查询淘宝天猫的宝贝类目
etcd集群权限管理和账号密码使用
Adc128s022 ADC Verilog design and Implementation
Luogu p3065 [usaco12dec]first! G problem solution
7-6 mixed type data format input
洛谷P5194 [USACO05DEC]Scales S 题解
C language,%d% Difference between 2D%2d%02d