注册 登录
编程论坛 新人交流区

一个C++的例题,能否有人给解释一下?自定义的两个函数不太明白什么意思?

五月草 发布于 2007-11-08 14:06, 377 次点击

#include <stdio.h>
#include <iostream.h>
const int K(5), N(6);
int sum_of_powers(int k,int n),int powers(int m,int n);
void main()
{
cout<<"sum of"<<K<<"powers of integers from 1 to"<<N<<"=";
cout<<sum_of_powers(K,N)<<endl;
}

int sum_of_powers(int k,int n);
{
int sum(0);
for (int i(1);i<=N;i++)
sum+=powers(i,K);
return sum;
}

int powers(int m,int n);
{
int product(1);
for(int i(1);i<=n;i++)
product*=m;
return product;
}

2 回复
#2
蝶梦痕2007-11-09 01:17

绿色的是阶乘,红色的是阶乘的和~~~

#3
dracula08032007-11-09 01:41
这样的 哦....
1