当前位置:网站首页>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;
}边栏推荐
- 洛谷P4047 [JSOI2010]部落划分 题解
- Table of mathematical constants by q779
- 7-18 finding the single root of polynomial by dichotomy
- GRPC的四种数据流以及案例
- C language,%d% Difference between 2D%2d%02d
- Sendmail无法发送邮件及发送过慢解决
- Tonybot humanoid robot checks the port and corresponds to port 0701
- Frequently asked questions: PHP LDAP_ add(): Add: Undefined attribute type in
- 7-15 calculation of PI
- Accelerating strategy learning using parallel differentiable simulation
猜你喜欢

retrofit

NPM install is stuck with various strange errors of node NPY

tonybot 人形机器人 首次开机 0630
![Luogu p4047 [jsoi2010] tribal division solution](/img/7f/3fab3e94abef3da1f5652db35361df.png)
Luogu p4047 [jsoi2010] tribal division solution

ConstraintLayout 的使用

泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东

pyQt界面制作(登录+跳转页面)

Detailed explanation of four modes of distributed transaction (Seata)

556. The next larger element III

Sword finger offer 28 Symmetric binary tree
随机推荐
7-22 tortoise and rabbit race (result oriented)
Find books ()
Luogu p3065 [usaco12dec]first! G problem solution
npm install卡住与node-npy的各种奇怪报错
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
JVM garbage collector
Four data flows and cases of grpc
PCB中常用快捷键
SSH访问控制,多次失败登录即封掉IP,防止暴力破解
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
中国锂电池电解液行业市场专项调研报告(2022版)
[clean up the extraordinary image of Disk C]
Tailing rushes to the scientific and Technological Innovation Board: it plans to raise 1.3 billion, and Xiaomi Changjiang is the shareholder
Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions
NPM install is stuck with various strange errors of node NPY
【北大青鸟昌平校区】互联网行业中,哪些岗位越老越吃香?
J-luggage lock of ICPC Shenyang station in 2021 regional games (simple code)
添加Zabbix计算类型项目Calculated items
556. 下一个更大元素 III
Creation of data table of Doris' learning notes