当前位置:网站首页>Zzuli:1040 sum of sequence 1
Zzuli:1040 sum of sequence 1
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 positive integer n.
Output
The result is reserved 2 Decimal place , Take a line alone
The sample input Copy
3
Sample output Copy
1.53
#include <stdio.h>
int main()
{
int n,i;
double t,den=1,sum=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
t=1/den;
sum=sum+t;
den=den+2;
}
printf("%.2lf",sum);
return 0;
}
边栏推荐
- 天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
- ShowMeBug入驻腾讯会议,开启专业级技术面试时代
- 556. The next larger element III
- 556. 下一个更大元素 III : 简单构造模拟题
- China PETG market forecast and Strategic Research Report (2022 Edition)
- C language,%d% Difference between 2D%2d%02d
- 【7.3】146. LRU caching mechanism
- Tonybot humanoid robot checks the port and corresponds to port 0701
- 编程语言:类型系统的本质
- Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
猜你喜欢
556. 下一个更大元素 III
tonybot 人形機器人 紅外遙控玩法 0630
Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not
Understanding of closures
Leetcode(4)——尋找兩個正序數組的中比特數
Zhonggan micro sprint technology innovation board: annual revenue of 240million, net loss of 17.82 million, proposed to raise 600million
提高效率 Or 增加成本,开发人员应如何理解结对编程?
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
Puzzle (016.4) domino effect
分布式事务(Seata) 四大模式详解
随机推荐
Luogu p4047 [jsoi2010] tribal division solution
修改数据库中的记录为什么报这个错
必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿
npm install卡住与node-npy的各种奇怪报错
tonybot 人形机器人 首次开机 0630
【7.3】146. LRU caching mechanism
ZABBIX saves the page blank after adding calculated items
分布式事务(Seata) 四大模式详解
Sub-GHz无线解决方案Z-Wave 800 系列ZG23 soc和ZGM230S模块
中国PETG市场预测及战略研究报告(2022版)
Common commands for getting started with mongodb database
DDK for XP
6-9 statistics of single digits (15 points)
愉悦资本新双币基金近40亿元完成首次关账
Common shortcut keys in PCB
提高效率 Or 增加成本,开发人员应如何理解结对编程?
pyQt界面制作(登录+跳转页面)
7-17 crawling worms (break exercise)
Tailing rushes to the scientific and Technological Innovation Board: it plans to raise 1.3 billion, and Xiaomi Changjiang is the shareholder
Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs