当前位置:网站首页>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;
}
边栏推荐
- 指针--剔除字符串中的所有数字
- ES全文索引
- Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
- 指針:最大值、最小值和平均值
- Load balancing ribbon of microservices
- Database monitoring SQL execution
- Wang Shuang's detailed learning notes of assembly language II: registers
- [paper reproduction] cyclegan (based on pytorch framework) {unfinished}
- SystemVerilog discusses loop loop structure and built-in loop variable I
- 《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
猜你喜欢
Based on authorized access, cross host, and permission allocation under sqlserver
Data mining - a discussion on sample imbalance in classification problems
Statistics, 8th Edition, Jia Junping, Chapter 6 Summary of knowledge points of statistics and sampling distribution and answers to exercises after class
What is an index in MySQL? What kinds of indexes are commonly used? Under what circumstances will the index fail?
Solutions to common problems in database development such as MySQL
JDBC read this article is enough
《统计学》第八版贾俊平第十二章多元线性回归知识点总结及课后习题答案
图书管理系统
《统计学》第八版贾俊平第七章知识点总结及课后习题答案
JVM memory model concept
随机推荐
How does SQLite count the data that meets another condition under the data that has been classified once
flask实现强制登陆
Summary of thread implementation
Based on authorized access, cross host, and permission allocation under sqlserver
指针 --按字符串相反次序输出其中的所有字符
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
Intel oneapi - opening a new era of heterogeneity
指針:最大值、最小值和平均值
Statistics 8th Edition Jia Junping Chapter 5 probability and probability distribution
《统计学》第八版贾俊平第五章概率与概率分布
浙大版《C语言程序设计实验与习题指导(第3版)》题目集
后台登录系统,JDBC连接数据库,做小案例练习
《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案
JDBC事务、批处理以及连接池(超详细)
【指针】八进制转换为十进制
数字电路基础(四) 数据分配器、数据选择器和数值比较器
[pointer] solve the last person left
浙大版《C语言程序设计实验与习题指导(第3版)》题目集
What is the transaction of MySQL? What is dirty reading and what is unreal reading? Not repeatable?
【指针】求解最后留下的人