wlc314lxy
2017-11-11 12:36哪位大神指教一下 result *= i;什么意思
#include
//求阶乘
long factorial(int n)
{
int i;
long result=1;
for(i=1; i<=n; i++)
{
result *= i;
}
return result;
}
// 求累加的和
long sum(long n)
{
int i;
long result = 0;
for(i=1; i<=n; i++)
{
//嵌套调用
result += factorial(i);
}
return result;
}
int main()
{
printf("1!+2!+...+9!+10! = %ld\n", sum(10));
return 0;
}
- 点赞
- 回答
- 收藏
- 复制链接分享
11条回答
为你推荐
- 项目中自定义的拦截器在没有接口请求的时候为什么一直在执行
- spring
- java
- ide
- 1个回答
- php如何解析获取这种格式的json
- php
- 1个回答
- 跨服务器上传数据一直出现UnknownHostException: loaclhost
- spring
- 服务器
- 2个回答
- softmax分类器,分类概率都是nan是怎么回事?
- python
- softmax
- 预测
- 测试
- 框架
- 2个回答
- php 数据库拿到数据放到数组
- 数据库
- php
- 数据
- 2个回答
换一换