I would want to write a C++ program to show combination..but I cant do it.May anyone help me to check my program and teach me to correct it ??
My goal id to input the n and k then it will show the combination to me.#include <iostream>
using namespace std;
int main()
{
int n,answer;
int j=1;
cout << "Input n and k :"<<endl;
cin >> n,k;
answer=(n - j + 1) / j ;
while(j<=k){
answer= answer *(n - j + 1) / j ;
++j ; }
cout<<"The number of combinations is :"<< answer << endl;
system("PAUSE");
return 0;
}
| « batch file to find duplic... | Java bits shifting within... » |