Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by Егор ( 14 years ago )
#include "stdafx.h"
#include <conio.h>
#include <iostream>
using namespace std;
int Combin2(int N,int K)
{
int result;
int C[20][20];
if(K==0 || N==K)
return 1;
else
{
if(C[N-1,K] == 0)
{
C[N-1][K] = Combin2(N-1,K);
C[N][K] = C[N-1][K] + Combin2(N-1,K-1);
Combin2(N,K); // Вот эта строчка
}
}
}
int main()
{
setlocale(0,"Rus");
int a,b,i,j;
int C[20][20];
for(i=1;i<20;i++)
for(j=0;j<20;j++)
C[i][j] = 0;
cout<< "Введите N = " ;
cin >> a;
cout<< "Введите K = " ;
cin >> b;
if(a<0 || a>20 || b<0 || b>a)
cout << "Неверно задано условие!" ;
else
cout << "Число сочитаний из " << a << " элементов по " << b << " = " << Combin2(a,b);
getch();
}
Revise this Paste