#include<stdio.h>
int f(int x,int y)
{
if(!x||!y) return 1;
return f(x-1,y)+f(x,y-1);
}
int main()
{
while(1)
{
int n,m;
scanf("%d%d",&n,&m);
printf("%d\n",f(n,m));
}return 0;
}
8.有m个A,n个B,用递归方法计算有多少种排列?提示分两种情况:如果第1个是A,则剩下m-1个A,n个B。如果第1个是B,则剩下m个A,n-1个B。
最新推荐文章于 2024-07-22 17:06:26 发布