当前位置:网站首页>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;
}
边栏推荐
- 《统计学》第八版贾俊平第三章课后习题及答案总结
- 王爽汇编语言详细学习笔记二:寄存器
- MySQL learning notes (stage 1)
- Numpy Quick Start Guide
- 《统计学》第八版贾俊平第二章课后习题及答案总结
- Query method of database multi table link
- Overview of LNMP architecture and construction of related services
- 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
- Database monitoring SQL execution
- 函数:求方程的根
猜你喜欢

Statistics 8th Edition Jia Junping Chapter 14 summary of index knowledge points and answers to exercises after class

Uibutton status exploration and customization

《统计学》第八版贾俊平第五章概率与概率分布

JVM memory model concept

How to earn the first pot of gold in CSDN (we are all creators)

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

Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?

Four methods of exchanging the values of a and B

Constants, variables, and operators of SystemVerilog usage

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
随机推荐
Wu Enda's latest interview! Data centric reasons
指针:最大值、最小值和平均值
图书管理系统
What is the transaction of MySQL? What is dirty reading and what is unreal reading? Not repeatable?
指針:最大值、最小值和平均值
5 minutes to master machine learning iris logical regression classification
Fire! One day transferred to go engineer, not fire handstand sing Conquest (in serial)
[pointer] octal to decimal
循环队列(C语言)
王爽汇编语言学习详细笔记一:基础知识
The difference between layer 3 switch and router
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
Constants, variables, and operators of SystemVerilog usage
{1,2,3,2,5}查重问题
Overview of LNMP architecture and construction of related services
王爽汇编语言详细学习笔记二:寄存器
Sentinel overall workflow
5分钟掌握机器学习鸢尾花逻辑回归分类
The common methods of servlet context, session and request objects and the scope of storing data in servlet.
[pointer] counts the number of times one string appears in another string