当前位置:网站首页>函数:计算组合数
函数:计算组合数
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
边栏推荐
- centos7安装mysql8
- Teach you how to kill if else
- 目前为止 DAO靠什么盈利?
- Tanabata is here - the romance of programmers
- 七夕到了——属于程序员的浪漫
- 「X」to「Earn」:赛道现状与破局思路
- js function anti-shake and function throttling and other usage scenarios
- 严格反馈非线性系统基于事件触发的自抗扰预设有限时间跟踪控制
- H.265视频流媒体播放器EasyPlayer.js集成时出现“SourceBuffer ”报错,该如何解决?
- CodeTON Round 2 A - D
猜你喜欢
随机推荐
最新真实软件测试面试题分享,收藏了还怕进入不了大厂?
创建型模式 - 简单工厂模式StaticFactoryMethod
mysql根据多字段分组——group by带两个或多个参数
threejs dynamically adjust the camera position so that the camera can see the object exactly
go context 包
Based on two levels of decomposition and the length of the memory network multi-step combined forecasting model of short-term wind speed
Token、Redis实现单点登录
gdb调试简要总结
TCP三次握手与四次挥手
CKA、CKAD、CKS、KCNA、CFCD考试
微信小程序(一)
WebShell 木马免杀过WAF
Go语言如何操作文件
redis的学习笔记
MySQL 用id分库使用name查询
测试ESP32-Zigbee转发命令 : 滑轨、继电器控制
Word2Vec词向量训练、使用及可视化操作
Rebound shell principle and implementation
基于STM32的FLASH读写实验含代码(HAL库)
JS Date 时间戳 getTune data.parse 倒计时小程序









