输入n,k两个数求1的K次方+2的K次方+...+n的K次方.
你说的是这个吗?
#include <stdio.h>
double init(int i,int k);
int main(void)
{
int i,n,k;
double sum=0,sum1;
printf("please input the number n:");
scanf("%d",&n);
printf("please input the number k:");
scanf("%d",&k);
for (i=1;i<=n;i++)
{
sum1=init(i,k);
sum+=sum1;
}
printf("the sum of the number is :%lf\n",sum);
return 0;
}
double init(int i,int k)
{
double sum=1;
while (k--)
sum*=i;
return sum;
}
[此贴子已经被作者于2007-4-18 9:06:41编辑过]