当前位置:网站首页>函数:计算组合数
函数:计算组合数
2022-08-02 22:23:00 【|光|】
要求
编写程序:输入两个正整数m,n(m>n),计算从m个元素中任取n个元素的组合数。
代码
#include<stdio.h>
/* * 该函数实现计算n的阶乘 */
double factorial(int n)
{
double i,j=1,k;
for(i=1;i<=n;i++)
{
j = j*i;
}
return j;
}
/* * 该函数实现计算组合,调用函数factorial实现 */
double combination(int n,int m)
{
double p;
p = factorial(m)/(factorial(n)*factorial(m-n));
return p;
}
测试
测试输入
3 9
输出
84
边栏推荐
猜你喜欢
随机推荐
浅读一下dotenv的主干逻辑的源码
万物智联时代,悄然走入生活
执子手,到永恒
CentOS7 安装MySQL 图文详细教程
go rand 包
In-depth study TypeScript TypeScript 】 【 class (under)
threejs 动态调整相机位置,使相机正好能看到对象
B站回应“HR 称核心用户都是 Loser”:该面试官去年底已被劝退,会吸取教训加强管理
Week 7 - Distributional Representations(分布表示)
学习基因富集工具DAVID(3)
IDO代币预售合约系统开发技术详细
msys2下载地址
谷粒商城-day14-商城业务与压力测试
【TypeScript】深入学习TypeScript模块化
Web APIs BOM- 操作浏览器-Window对象
Tanabata is here - the romance of programmers
Jmeter二次开发实现rsa加密
刚安装完win10专业工作站版,系统变量中Path默认值有哪些?重新建一个“PATH”变量名,会覆盖掉原先的“Path”。
Matplotlib drawing core principles explain (more detailed)
非关系型数据库MongoDB简介和部署






![[TypeScript] Deep Learning of TypeScript Classes (Part 1)](/img/47/34954f1e01b844816d74f3ac556f9b.png)


