文章
55
粉丝
100
获赞
12
访问
31.0k
#include <iostream>
#include <vector>
#include<string>
#include<malloc.h>
#include<algorithm>
#include<math.h>
using namespace std;
int recursion(int n){
if(n == 1){
return 1;
}
return n*recursion(n-1);
}
int main(){
int n,r;
while(cin>>n>>r && (n!=0 || r!=0)){
int sum = 1;
int j = 0;
if(n == r || r == 0){
cout<<1<<endl;
continue;
}else if(r>n){
cout<<"error!"<<endl;
continue;
}else{
for(int i = n,j = 0; j < r; j++){
sum *= i;
i--;
}
int rs = recursion(r);
int res = sum/rs;
cout<<res<<endl;
}
}
}
登录后发布评论
暂无评论,来抢沙发