// ========================================================== ==========================================
// Name: forjob. cpp
// Author: yangyh
// Version:
// Copyright: Your copyright notice
// Description: Hello world in C ++, ANSI-style
// ========================================================== ==========================================
// Select all combinations of n characters from M characters
# Include < Iostream >
Using Namespace STD;
Static Int M = 0 ;
Int Print ( Const Char * SRC, Int Begin, Int Len, Char * DST, Int Index, Int N ){
If (N = 0 ){
DST [Index] = ' \ 0 ' ;
Printf ( " % D: % s \ n " , M ++ , DST );
Return 1 ;
}
If (Len < N)
Return 0 ;
For ( Int I = Begin; I < Len; I ++ ){
DST [Index] = SRC [I];
Print (SRC, I + 1 , Len, DST, Index + 1 , N - 1 );
}
Return 1 ;
}
Int Main ( Int Argc, Char * Argv []) {
Printf ( " Hello world! \ N " );
Char STR [ 10 ] = " Abcdefgh " ;
Char DST [ 10 ];
Print (STR, 0 , 8 , DST, 0 , 3 ); // Find all combinations of 3 characters from 8 characters
Printf ( " Total: % d \ n " , M );
Return 0 ;
}