当前位置:网站首页>2.5 find the sum of the first n terms of the square root sequence
2.5 find the sum of the first n terms of the square root sequence
2022-06-25 19:57:00 【Then peace and happiness】
This question requires the preparation of procedures , Calculate the sequence of square roots √1+√2+√3+⋯ Before N Sum of items . Can contain header files math.h, And call sqrt The square root of a function .
Input format :
Input gives a positive integer on a line N.
Output format :
In a row, press “sum = S” The format of the output part and the value of S, Accurate to two decimal places . The calculation results should not exceed the double precision range .
sample input :
10
sample output :
sum = 22.47Reference code :
#include<stdio.h>
#include<math.h>
int main(){
int i, n;
double a, sum;
scanf("%d",&n);
sum=0;
for(i=1;i<=n;i++){
a=sqrt(i);
sum=sum+a;
}
printf("sum = %.2lf\n",sum);
return 0;
} 边栏推荐
- Vscode debugging PHP configuration Xdebug
- Is it safe to open an online account for new bonds? What should be paid attention to
- 2.16([Usaco2005 Nov]Ant Counting)
- JS get the parameters in the URL link
- System optimization method
- 在打新債開戶證券安全嗎?低傭金靠譜嗎
- Network security detection and prevention exercises (III)
- Tcp/ip test questions (4)
- ActiveMQ--CVE-2016-3088
- Principles of MySQL clustered index and non clustered index
猜你喜欢

Web container basic configuration

Suddenly found that the screen adjustment button can not be used and the brightness can not be adjusted

PAT B1076

One night I worked as an XPath Terminator: XPath Helper Plus

Trend ea- fixed stop loss and profit per order

Vulnhub range - correlation:2

Single chip microcomputer line selection method to store impression (address range) method + Example

Divine reversion EA

Lilda Bluetooth air conditioning receiver helps create a more comfortable road life

On Oracle full stack virtual machine -- graalvm
随机推荐
Redis cache preheating & avalanche & breakdown & penetration
Does GoogleSEO need to change the friend chain? (e6zzseo)
From now on, I will blog my code
Network security detection and prevention test questions (II)
PAT B1056
3、 Hikaricp source code analysis of connection acquisition process III
The meanings of /32, /48, /64 in IPv6 addresses
2.14(Knight Moves)
Vulnhub range - the planes:venus
请问通达信开户安全吗?
Vulnhub range the planes:earth
rmi-registry-bind-deserialization
Network security detection and prevention test questions (4)
JS asynchronism (III. usage of generator and async/await)
Profile path and name
LNMP compilation and installation
New features of php7
Record Baidu search optimization thinking analysis
打新债证券开户安全吗
Laravel validation rule followed Role of auth:: id()