当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
Use of constraintlayout
MySQL multi table query subquery
Jiuyi cloud black free encryption free version source code
泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
Code writing and playing method of tonybot humanoid robot at fixed distance
Tonybot humanoid robot infrared remote control play 0630
Tonybot humanoid robot starts for the first time 0630
X86 assembly language - Notes from real mode to protected mode
分布式事务(Seata) 四大模式详解
pyQt界面制作(登录+跳转页面)
随机推荐
Convert string to decimal integer
Thread. Sleep and timeunit SECONDS. The difference between sleep
7-23 currency conversion (using array conversion)
tonybot 人形机器人 查看端口并对应端口 0701
Table of mathematical constants by q779
etcd集群权限管理和账号密码使用
ShowMeBug入驻腾讯会议,开启专业级技术面试时代
556. The next larger element III
【7.3】146. LRU缓存机制
牛客网:过河卒
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
【7.3】146. LRU caching mechanism
Zhonggan micro sprint technology innovation board: annual revenue of 240million, net loss of 17.82 million, proposed to raise 600million
[qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?
亚马逊、速卖通、Lazada、Shopee、eBay、wish、沃尔玛、阿里国际、美客多等跨境电商平台,测评自养号该如何利用产品上新期抓住流量?
Luogu p5194 [usaco05dec]scales s solution
Analysis of gene family characteristics - chromosome location analysis
Etcd cluster permission management and account password usage
fpga阻塞赋值和非阻塞赋值
Stop asking yourself if you are suitable for software testing