当前位置:网站首页>浙大版《C语言程序设计实验与习题指导(第3版)》题目集
浙大版《C语言程序设计实验与习题指导(第3版)》题目集
2022-07-06 09:23:00 【无二三事】
实验5-7 使用函数求1到10的阶乘和
分数 10
全屏浏览题目
切换布局
作者 张高燕
单位 浙大城市学院
本题要求实现一个计算非负整数阶乘的简单函数,使得可以利用该函数,计算1!+2!+⋯+10!的值。
函数接口定义:
double fact( int n );
其中n是用户传入的参数,其值不超过10。如果n是非负整数,则该函数必须返回n的阶乘。
裁判测试程序样例:
#include <stdio.h> double fact( int n ); int main(void) { int i; double sum; sum = 0; for(i = 1; i <= 10; i++) sum = sum + fact(i); printf("1!+2!+...+10! = %f\n", sum); return 0; } /* 你的代码将被嵌在这里 */
输入样例:
本题没有输入。
输出样例:
1!+2!+...+10! = 4037913.000000
代码长度限制
16 KB
时间限制
400 ms
内存限制
64 MB
代码具体实现:
double fact( int n ){
int i = 1;
for(int j=1;j<=n;j++){
i *= j;
}
return i;
}
边栏推荐
- How to understand the difference between technical thinking and business thinking in Bi?
- 记一次api接口SQL注入实战
- The most popular colloquial system explains the base of numbers
- Attack and defense world misc practice area (GIF lift table ext3)
- JDBC transactions, batch processing, and connection pooling (super detailed)
- 7-6 local minimum of matrix (PTA program design)
- MySQL learning notes (stage 1)
- 网络基础之路由详解
- Interpretation of iterator related "itertools" module usage
- Hackmyvm target series (5) -warez
猜你喜欢

Internet Management (Information Collection)
![New version of postman flows [introductory teaching chapter 01 send request]](/img/0f/a41a39093a1170cc3f62075fd76182.jpg)
New version of postman flows [introductory teaching chapter 01 send request]

Hackmyvm target series (1) -webmaster

Experiment 6 inheritance and polymorphism

Uibutton status exploration and customization

内网渗透之内网信息收集(二)

内网渗透之内网信息收集(五)

List and data frame of R language experiment III

Attack and defense world misc practice area (GIF lift table ext3)

《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
随机推荐
Ucos-iii learning records (11) - task management
《统计学》第八版贾俊平第七章知识点总结及课后习题答案
搭建域环境(win)
Experiment 7 use of common classes
msf生成payload大全
《统计学》第八版贾俊平第四章总结及课后习题答案
Intranet information collection of Intranet penetration (5)
Library management system
Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
《统计学》第八版贾俊平第十二章多元线性回归知识点总结及课后习题答案
Interpretation of iterator related "itertools" module usage
Realize applet payment function with applet cloud development (including source code)
SQL injection
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
Experiment 6 inheritance and polymorphism
[issue 18] share a Netease go experience
7-6 local minimum of matrix (PTA program design)
MSF generate payload Encyclopedia
HackMyvm靶机系列(4)-vulny
图书管理系统