Ken H

Ken H

  • NA
  • 646
  • 355k

Combinations number in c language

Dec 21 2013 7:22 AM
hello friend,
        How to use a combination number of non-recursive functions?
//  Codes:
#include<stdio.h>
void C(int a[],int n,int m){
   // How to do it?

}
void C(char b[],int n,int m){
  // How to do it? 
}
void main()
{

int a[5]={1,2,3,4,5};

char b[]={"abcde"};

C(a,5,3);  // It should be 10 combinations.

C(b,5,3); // Same as above.

}
 
Here is its formula:

Such as: 
 C(a,5,3);
It will print the following information:
123
124
125
134
135
145 
234
235
245
345 
Total:10
C(b,5,3);
It will print the following information:
abc
abd
abe
acd
ace
ade
bcd
bce
bde
cde 
Total:10 
Please use a non-recursive method to solve it(Do not use the system to provide any built-in functions). And explain its problem-solving ideas.
Thank for you.:)

Answers (8)