当前位置:网站首页>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;
}
边栏推荐
- 表单文本框的使用(一) 选择文本
- Stop asking yourself if you are suitable for software testing
- 7-14 sum integer segments (C language)
- Some concepts about agile
- 光猫超级账号密码、宽带账号密码 获取
- Convert string to decimal integer
- Recent learning summary
- puzzle(016.3)千丝万缕
- Code writing and playing method of tonybot humanoid robot at fixed distance
- 动态获取权限
猜你喜欢
Creation of data table of Doris' learning notes
Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs
一文了解微分段应用场景与实现机制
Mysql多表查询 #子查询
中感微冲刺科创板:年营收2.4亿净亏1782万 拟募资6亿
Tonybot humanoid robot infrared remote control play 0630
Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them
x86汇编语言-从实模式到保护模式 笔记
NPM install is stuck with various strange errors of node NPY
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
随机推荐
Jiuyi cloud black free encryption free version source code
Adc128s022 ADC Verilog design and Implementation
Creation of data table of Doris' learning notes
Luogu p3065 [usaco12dec]first! G problem solution
The mail function of LNMP environment cannot send mail
China PETG market forecast and Strategic Research Report (2022 Edition)
7-17 crawling worms (break exercise)
Common shortcut keys in PCB
中国PETG市场预测及战略研究报告(2022版)
关于敏捷的一些概念
Sendmail can't send mail and it's too slow to send. Solve it
论文分享:Generating Playful Palettes from Images
Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them
Doris学习笔记之数据表的创建
556. The next larger element III
puzzle(016.4)多米诺效应
7-28 monkeys choose King (Joseph problem)
Frequently asked questions: PHP LDAP_ add(): Add: Undefined attribute type in
Thread.sleep和TimeUnit.SECONDS.sleep的区别
Get permissions dynamically