fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int n;
  5. string s;
  6.  
  7. void go(int n, string cur = "" ) {
  8. if (!n) {
  9. cout << cur << "\n";
  10. return;
  11. }
  12. for (auto c: s)
  13. go(n - 1, cur + c);
  14. }
  15.  
  16. int main() {
  17. cin >> s >> n;
  18. go(n);
  19. }
Success #stdin #stdout 0s 4176KB
stdin
+6A
2
stdout
++
+6
+A
6+
66
6A
A+
A6
AA