当前位置:网站首页>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.47
Reference 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;
}
边栏推荐
- On Oracle full stack virtual machine -- graalvm
- Miner's Diary: why should I go mining on April 5, 2021
- Force wechat page font size to be 100%
- Error record: preg_ match(): Compilation failed: range out of order in character class at offset 13
- Redis cache preheating & avalanche & breakdown & penetration
- PHP Chinese regular
- Jsonp processing non homologous
- Solve the problem that sublime Text3 package control cannot install plug-ins
- Installing or uninstalling VMware could not find the network location
- Can GoogleSEO only do content without external chain? (e6zzseo)
猜你喜欢
Applet password input box
Print 1 cute every 100 milliseconds ~ with a running lantern effect
Verification code native JS canvas
Vulnhub range - the planes:venus
Vulnhub range the planes:earth
Bindgetuserinfo will not pop up
Hdoj topic 2005 day
Miner's Diary: why should I go mining on April 5, 2021
Ali visual AI training camp -day05- creativity day - your image recognition project
Apifox simple understanding -- the integrator of web side testing
随机推荐
Connecting PHP to MySQL instances in the lamp environment of alicloud's liunx system
Embark on a new journey and reach the world with wisdom
PAT B1057
The meanings of /32, /48, /64 in IPv6 addresses
一、HikariCP获取连接流程源码分析一
Alicloud centos8.0 installing mysql8
VMware failed to prompt to lock this profile exclusively
PAT B1091
LNMP compilation and installation
Wechat applet cloud function does not have dependency option installed
Vscode debugging PHP configuration Xdebug
Wechat applet connects to the server to display mqtt data information
Network security detection and prevention test questions (V)
Pdf file download (the download name is the same as the file name)
Ali visual AI training camp -day05- creativity day - your image recognition project
Read multiple associations from a field using delimiters in laravel
Randomly generate 100 non repeating numbers between 1 and 150 and put them in the array
在打新债开户证券安全吗
Jsonp function encapsulation
Google cloud SSH enable root password login