当前位置:网站首页>功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
2022-07-04 00:33:00 【CTGU-Yoghurt】
题目:
代码详解:
#define K 4
#define N 5
#include <stdio.h>
long fun(int n, int k)
{
/**********Program**********/
long sum = 1,i,j,t;
for (i = 2; i <= n; i++)
{
t = 1;
for (j = 1; j <= k; j++)
{
t *= i;
}
sum += t;
}
return sum;
/********** End **********/
}
int main()
{
long int sum;
printf("Sum of %d powers of integers from 1 to %d = ", K, N);
sum = fun(N, K);
printf("%ld\n", sum);
}
边栏推荐
- Bodong medical sprint Hong Kong stocks: a 9-month loss of 200million Hillhouse and Philips are shareholders
- Shell script three swordsman sed
- Test the influence of influent swacth on the electromagnetic coil of quartz meter
- Make small tip
- Global and Chinese markets of distributed control system (DCS) consumption 2022-2028: Research Report on technology, participants, trends, market size and share
- Iclr2022: how does AI recognize "things I haven't seen"?
- From functools import reduce -- see the use of reduce function from typical examples
- 想请教一下,十大劵商如何开户?在线开户是安全么?
- Regular expressions and text processors for shell programming
- Att & CK actual combat series - red team actual combat - V
猜你喜欢
Investment demand and income forecast report of China's building ceramics industry, 2022-2028
On the day when 28K joined Huawei testing post, I cried: everything I have done in these five months is worth it
Is user authentication really simple
Reading notes on how programs run
[error record] configure NDK header file path in Visual Studio
Qtcharts notes (V) scatter diagram qscatterseries
China standard gas market prospect investment and development feasibility study report 2022-2028
Pytest unit test framework: simple and easy to use parameterization and multiple operation modes
NLP pre training technology development
A Kuan food rushed to the Shenzhen Stock Exchange: with annual sales of 1.1 billion, Hillhouse and Maotai CCB are shareholders
随机推荐
Global and Chinese market of process beer equipment 2022-2028: Research Report on technology, participants, trends, market size and share
Gossip about redis source code 74
Makefile judge custom variables
Bodong medical sprint Hong Kong stocks: a 9-month loss of 200million Hillhouse and Philips are shareholders
No qualifying bean of type ‘com. netflix. discovery. AbstractDiscoveryClientOptionalArgs<?>‘ available
Suggestions for improving code quality
Selenium library 4.5.0 keyword explanation (4)
Stock price forecast
I would like to ask how the top ten securities firms open accounts? Is it safe to open an account online?
Global and Chinese markets for coronary artery disease treatment devices 2022-2028: Research Report on technology, participants, trends, market size and share
AI Challenger 2018 text mining competition related solutions and code summary
Pair
What is the Valentine's Day gift given by the operator to the product?
HR disgusted interview behavior
Software testers, how can you quickly improve your testing skills? Ten minutes to teach you
[PHP basics] session basic knowledge, application case code and attack and defense
Regular expressions and text processors for shell programming
Solve the problem that the kaggle account registration does not display the verification code
Entropy and full connection layer
Selenium library 4.5.0 keyword explanation (II)