1 parent ad096e5 commit 833b913Copy full SHA for 833b913
1 file changed
homework1/src/problem2.cpp
@@ -0,0 +1,23 @@
1
+#include <iostream>
2
+#include <cmath>
3
+using namespace std;
4
+
5
+int main() {
6
+ char S[] = { 'a', 'b', 'c' };
7
+ int n = 3;
8
+ int total = pow(2, n);
9
10
+ for (int i = 0; i < total; ++i) {
11
+ cout << "{";
12
+ bool first = true;
13
+ for (int j = 0; j < n; ++j) {
14
+ if (i & (1 << j)) {
15
+ if (!first) cout << ", ";
16
+ cout << S[j];
17
+ first = false;
18
+ }
19
20
+ cout << "}" << endl;
21
22
+ return 0;
23
+}
0 commit comments