求高手帮忙编辑一个程序,挺简单的程序,求帮忙了,然后请帮忙运行下,没错的立即采纳,谢谢

2025-01-04 12:42:43
推荐回答(2个)
回答1:

?是将r个字母或整数在屏幕上打印出来,还是输出有多少种排列组合方法?打印的话够呛,很麻烦。直接写多少种的话就太简单了。
排列数函数:

unsigned long CC(unsigned int n,unsigned int r)
{
unsigned int i=n,j=r;
unsigned long temp_n=1;
unsigned long temp_r=1;

while(i>r)
{
i--;
temp_n = temp_n*(unsigned long)i;
}
while(j>0)
{
j--;
temp_r = temp_r*(unsigned long)j;
}
return(temp_n/temp_r);
}

组合数函数:

unsigned long AA(unsigned int n,unsigned int r)
{
unsigned int temp=n;
unsigned long result=1;

while(temp>r)
{
temp--;
result = result*temp;
}
return(result);
}

回答2:

已发送,请查收