当前位置:网站首页>函数:计算组合数
函数:计算组合数
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
边栏推荐
猜你喜欢
随机推荐
Week 7 - Distributional Representations(分布表示)
H5网页播放器EasyPlayer.js播放器界面的加载效果无法消失是什么原因?
MySQL 用id分库使用name查询
gdb调试简要总结
无代码开发平台数据ID入门教程
VS保存后Unity不刷新
Image recognition from zero to write DNF script key points
How many ways do you know the singleton pattern?
00 -- jieba分词
创建型模式 - 单例模式Singleton
JS 包装类 Math对象 round max() min() random
IDO代币预售合约系统开发技术详细
group of people
【Unity】Unity开发进阶(六)UnityEvent使用与源码解析
Web APIs BOM- 操作浏览器-Window对象
基于两级分解和长短时记忆网络的短期风速多步组合预测模型
【使用pyside2遇到的问题】This application failed to start because no Qt platform plugin could be initialized.
软件测试到底自学还是报班?
采用QT进行OpenGL开发(三)着色器编程
Based on two levels of decomposition and the length of the memory network multi-step combined forecasting model of short-term wind speed