当前位置:网站首页>浙大版《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;
}
边栏推荐
- Wei Shen of Peking University revealed the current situation: his class is not very good, and there are only 5 or 6 middle-term students left after leaving class
- Overview of LNMP architecture and construction of related services
- 《统计学》第八版贾俊平第一章课后习题及答案总结
- MySQL learning notes (stage 1)
- 记一次api接口SQL注入实战
- 安全面试之XSS(跨站脚本攻击)
- Force deduction 152 question multiplier maximum subarray
- Intel oneapi - opening a new era of heterogeneity
- What language should I learn from zero foundation. Suggestions
- JDBC事务、批处理以及连接池(超详细)
猜你喜欢

Constants, variables, and operators of SystemVerilog usage

Middleware vulnerability recurrence Apache

Hackmyvm target series (1) -webmaster

小程序web抓包-fiddler

攻防世界MISC练习区(gif 掀桌子 ext3 )

Low income from doing we media? 90% of people make mistakes in these three points

How does SQLite count the data that meets another condition under the data that has been classified once

HackMyvm靶机系列(4)-vulny

sqqyw(淡然点图标系统)漏洞复现和74cms漏洞复现

Résumé des points de connaissance et des réponses aux exercices après la classe du chapitre 7 de Jia junping dans la huitième édition des statistiques
随机推荐
攻防世界MISC练习区(SimpleRAR、base64stego、功夫再高也怕菜刀)
HackMyvm靶机系列(3)-visions
《统计学》第八版贾俊平第二章课后习题及答案总结
Database monitoring SQL execution
Web vulnerability - File Inclusion Vulnerability of file operation
Constants, variables, and operators of SystemVerilog usage
小程序web抓包-fiddler
Interpretation of iterator related "itertools" module usage
Statistics 8th Edition Jia Junping Chapter 14 summary of index knowledge points and answers to exercises after class
内网渗透之内网信息收集(四)
Hackmyvm target series (6) -videoclub
Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
7-15 h0161. Find the greatest common divisor and the least common multiple (PTA program design)
"Gold, silver and four" job hopping needs to be cautious. Can an article solve the interview?
Solutions to common problems in database development such as MySQL
[VMware abnormal problems] problem analysis & Solutions
Applet Web Capture -fiddler
Uibutton status exploration and customization
JDBC事务、批处理以及连接池(超详细)
Build domain environment (win)