当前位置:网站首页>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;
}边栏推荐
- Tonybot humanoid robot starts for the first time 0630
- Mongodb index
- String substitution
- dllexport和dllimport
- Special research report on the market of lithium battery electrolyte industry in China (2022 Edition)
- Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
- 7-6 mixed type data format input
- Tiantu investment sprint Hong Kong stocks: asset management scale of 24.9 billion, invested in xiaohongshu and Naixue
- 7-16 find the set of integers that meet the given conditions
- Thread.sleep和TimeUnit.SECONDS.sleep的区别
猜你喜欢

Leetcode (4) -- find the median of two positively ordered arrays

Puzzle (016.3) is inextricably linked

adc128s022 ADC verilog设计实现

Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not

Zhonggan micro sprint technology innovation board: annual revenue of 240million, net loss of 17.82 million, proposed to raise 600million

7-18 finding the single root of polynomial by dichotomy

Understanding of closures

Puzzle (016.4) domino effect

Leetcode(4)——尋找兩個正序數組的中比特數

Protobuf and grpc
随机推荐
Strategy, tactics (and OKR)
Luogu p5194 [usaco05dec]scales s solution
7-28 monkeys choose King (Joseph problem)
556. The next larger element III
2021年区域赛ICPC沈阳站J-Luggage Lock(代码简洁)
Get permissions dynamically
Common commands for getting started with mongodb database
Protobuf and grpc
6-9 statistics of single digits (15 points)
7-16 find the set of integers that meet the given conditions
Luogu p3065 [usaco12dec]first! G problem solution
Recent learning summary
npm install卡住与node-npy的各种奇怪报错
retrofit
ConstraintLayout 的使用
Time conversion ()
556. 下一个更大元素 III
关于敏捷的一些概念
PCB中常用快捷键
Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)