当前位置:网站首页>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;
}边栏推荐
- Jiuyi cloud black free encryption free version source code
- 数学常数表 by q779
- Strategy, tactics (and OKR)
- 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 p3065 [usaco12dec]first! G problem solution
- 洛谷P5194 [USACO05DEC]Scales S 题解
- Programming language: the essence of type system
- SSH访问控制,多次失败登录即封掉IP,防止暴力破解
- NPM install is stuck with various strange errors of node NPY
- 牛客网:过河卒
猜你喜欢
随机推荐
C library function - qsort()
x86汇编语言-从实模式到保护模式 笔记
[clean up the extraordinary image of Disk C]
Sword finger offer 28 Symmetric binary tree
Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions
556. The next larger element III
Recent learning summary
Detailed explanation of four modes of distributed transaction (Seata)
亚马逊、速卖通、Lazada、Shopee、eBay、wish、沃尔玛、阿里国际、美客多等跨境电商平台,测评自养号该如何利用产品上新期抓住流量?
一文了解微分段应用场景与实现机制
ShowMeBug入驻腾讯会议,开启专业级技术面试时代
FPGA blocking assignment and non blocking assignment
Mongodb index
How to query the baby category of tmall on Taobao
Luogu p5194 [usaco05dec]scales s solution
洛谷P3065 [USACO12DEC]First! G 题解
洛谷P4047 [JSOI2010]部落划分 题解
Sub-GHz无线解决方案Z-Wave 800 系列ZG23 soc和ZGM230S模块
Eight sorts
必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿







![洛谷P5018 [NOIP2018 普及组] 对称二叉树 题解](/img/89/da1a3a38e02671628f385de0f30369.png)

