File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Text ;
5
+ using System . Threading . Tasks ;
6
+
7
+ namespace Secret
8
+ {
9
+ public partial class Program
10
+ {
11
+ static void Main ( string [ ] args )
12
+ {
13
+ combination ( "ABCD" ) ;
14
+ Console . ReadLine ( ) ;
15
+ }
16
+
17
+ public static void combination ( string str )
18
+ {
19
+ int len = 1 ;
20
+ for ( int i = 0 ; i < str . Length ; i ++ ) { len *= 2 ; }
21
+ len -= 1 ;
22
+ int count = 0 ;
23
+ string [ ] ch = new string [ len ] ;
24
+ for ( int i = str . Length - 1 ; i >= 0 ; i -- )
25
+ {
26
+ int l = count ;
27
+ for ( int j = 0 ; j < l ; j ++ )
28
+ {
29
+ ch [ count ++ ] = str [ i ] + ch [ j ] ;
30
+ }
31
+ ch [ count ++ ] = str [ i ] . ToString ( ) ;
32
+ }
33
+
34
+ for ( int i = 0 ; i < len ; i ++ )
35
+ {
36
+ Console . WriteLine ( ch [ i ] . ToString ( ) ) ;
37
+ }
38
+ }
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments