我怀疑,这一学习成果之一是什么,这里的帮助太大了。
我认为,我可以安全地说,你需要打破每一部分的公式,将其分成小部分。
The three biggest parts are summation, N Factorial (N!) and 2 to the power N
传票实际上从1岁起至19岁,因此,C syntax要写假(有两种共同类型,而为)
其余两项职能是,如果你允许使用预设职能,那么lent光只剩下一条 go子,可以 sort笑你,如果不是你自己的话。
系数:n*(n-1)*(n-2)...(n-(n-2))*(n-(n-1))
∗∗∗∗∗
http://www.google.co.uk/search?q=recursion”rel=“nofollow” 或带有倾斜性的功能
2 ×2 ×
页: 1
页: 1
Once again a loop looks like a good place to start with that.
之后,它只是利用你在坡道内的两个功能,让用户有办法投入Y,并用一些数字进行测试。
1,2,3美元将是一个良好的开端,因为它们重新 n,很容易就计算器开展工作。
我 hope希望,1人应当对我所看到的迄今所展示的每一个例子作出令人感兴趣的事情,在我们开始把大船推向32人之前就这样做了。
Edit:
Right, I ve taken a look at your code, and it looks like your problem isn t in the implementation of your algorithm, its not reading the variable in correctly, outputing y just after you set it yields 0, so something isn t working quite right there. Im not a c coder but i had a quick hack at it with some liberal googling and your non functional code and made it read an argument in then parse it to a double.
#include<stdio.h>
#include<math.h>
double factorial(double x);
double Power_function(double y);
main(int argc, char *argv[]){
double answer=0;
double n;
double y;
y = atol(argv[1]);
//printf("%lf
",y);
for (n=1;n<=y;++n){
answer=answer +factorial(n)*Power_function(n)*y;
}
printf("The Answer is %0.2f
",answer);
return 0;
}
double factorial(double x)
{
double ans;
if (x==0){
ans = 1;
}
else
{
ans = x*factorial(x-1);
}
return ans;
}
double Power_function(double y){
double ans;
ans=pow(2,y);
return ans;
}
因此,基本上来说,你的法典有不同的投入方法。
汇编
gcc so.c -lm
执行
./a.out 1
yields The Answer is 2.00
./a.out 2
yields The Answer is 20.00
./a.out 3
yields The Answer is 174.00
纸浆和纸面数字支持这一方法,因此,迄今为止,你的算法是健全的!
要求看到来自这里的一些负面数字和大量的数字!