当前位置:网站首页>Zhejiang University Edition "C language programming experiment and exercise guide (3rd Edition)" topic set
Zhejiang University Edition "C language programming experiment and exercise guide (3rd Edition)" topic set
2022-07-06 14:42:00 【No two or three things】
experiment 5-7 Use the function to find 1 To 10 Factorials of and
fraction 10
Full screen browsing topics
Switch layout
author Zhang Gaoyan
Company Zhejiang University City College
This problem requires a simple function to calculate the factorial of non negative integers , Makes it possible to use this function , Calculation 1!+2!+⋯+10! Value .
Function interface definition :
double fact( int n );
among n
Is the parameter passed in by the user , Its value does not exceed 10. If n
Is a nonnegative integer , Then the function must return n
The factorial .
Sample referee test procedure :
#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; } /* Your code will be embedded here */
sample input :
There is no input for this question .
sample output :
1!+2!+...+10! = 4037913.000000
Code length limit
16 KB
The time limit
400 ms
Memory limit
64 MB
Code implementation :
double fact( int n ){
int i = 1;
for(int j=1;j<=n;j++){
i *= j;
}
return i;
}
边栏推荐
- 《统计学》第八版贾俊平第七章知识点总结及课后习题答案
- Function: find 1-1/2+1/3-1/4+1/5-1/6+1/7-... +1/n
- MySQL learning notes (stage 1)
- MySQL中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?
- Based on authorized access, cross host, and permission allocation under sqlserver
- Constants, variables, and operators of SystemVerilog usage
- Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
- How to test whether an object is a proxy- How to test if an object is a Proxy?
- Chain team implementation (C language)
- Internet Management (Information Collection)
猜你喜欢
关于超星脚本出现乱码问题
关于交换a和b的值的四种方法
后台登录系统,JDBC连接数据库,做小案例练习
数字电路基础(三)编码器和译码器
Binary search tree concept
Attack and defense world misc practice area (GIF lift table ext3)
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
On the idea of vulnerability discovery
Library management system
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
随机推荐
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
【指针】统计一字符串在另一个字符串中出现的次数
XSS (cross site scripting attack) for security interview
《统计学》第八版贾俊平第三章课后习题及答案总结
Functions: Finding Roots of equations
Interview Essentials: what is the mysterious framework asking?
指针--剔除字符串中的所有数字
Circular queue (C language)
Sentinel overall workflow
How to earn the first pot of gold in CSDN (we are all creators)
“Hello IC World”
Network technology related topics
Bing Dwen Dwen official NFT blind box will be sold for about 626 yuan each; JD home programmer was sentenced for deleting the library and running away; Laravel 9 officially released | Sifu weekly
函数:字符串反序存放
函数:用牛顿迭代法求方程的根
Mathematical modeling idea of 2022 central China Cup
Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
数字电路基础(二)逻辑代数
【指针】求解最后留下的人
《统计学》第八版贾俊平第十三章时间序列分析和预测知识点总结及课后习题答案