?是将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);
}
已发送,请查收