当前位置:网站首页>浙大版《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;
}
边栏推荐
- This article explains in detail how mockmvc is used in practical work
- 《统计学》第八版贾俊平第七章知识点总结及课后习题答案
- Record once, modify password logic vulnerability actual combat
- WEB漏洞-文件操作之文件包含漏洞
- DVWA (5th week)
- Record an API interface SQL injection practice
- How to turn wechat applet into uniapp
- 循环队列(C语言)
- An unhandled exception occurred when C connected to SQL Server: system Argumentexception: "keyword not supported:" integrated
- Intranet information collection of Intranet penetration (4)
猜你喜欢
Uibutton status exploration and customization
内网渗透之内网信息收集(二)
JDBC read this article is enough
Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
《统计学》第八版贾俊平第十三章时间序列分析和预测知识点总结及课后习题答案
Xray and burp linkage mining
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
内网渗透之内网信息收集(三)
Hackmyvm target series (7) -tron
内网渗透之内网信息收集(一)
随机推荐
Attack and defense world misc practice area (GIF lift table ext3)
Based on authorized access, cross host, and permission allocation under sqlserver
内网渗透之内网信息收集(五)
记一次api接口SQL注入实战
SQL注入
Record an API interface SQL injection practice
《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
Experiment 7 use of common classes
Force deduction 152 question multiplier maximum subarray
The United States has repeatedly revealed that the yield of interest rate hiked treasury bonds continued to rise
DVWA (5th week)
《统计学》第八版贾俊平第十二章多元线性回归知识点总结及课后习题答案
外网打点(信息收集)
Intranet information collection of Intranet penetration (2)
Chain team implementation (C language)
Only 40% of the articles are original? Here comes the modification method
JDBC事务、批处理以及连接池(超详细)
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
List and data frame of R language experiment III
sqqyw(淡然点图标系统)漏洞复现和74cms漏洞复现