Advertisement
Dzham

Untitled

Dec 3rd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. #include <bitset>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. int n;
  10. cin >> n;
  11. string s;
  12. vector<string> res = {};
  13. for (int i = 0; i < n; i++) {
  14. cin >> s;
  15. res.push_back(s);
  16. }
  17. for (auto i = 0; i < (1 << res.size()); ++i) {
  18. bitset<32> b(i);
  19. string pr;
  20. for (auto j = 0; j < res.size(); j++) {
  21. if (b[j]) {
  22. pr += res[j];
  23. pr += ",";
  24. }
  25. }
  26. if (!pr.empty()) {
  27. pr.pop_back();
  28. }
  29. cout << "[" << pr << "]" << endl;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement