Altered Algorithm

This commit is contained in:
e2hang
2025-09-01 19:49:15 +08:00
parent e162486df1
commit 9c30eb42e2
15 changed files with 954 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
#include <iostream>
#include <vector>
using namespace std;
template <class T>
void dfs(vector<T>& _path, int n) {
if(_path.size() == n){
for(auto x : _path) cout << x << " ";
cout << endl;
return;
}
for(int i = 0; i < n; i++){
_path.push_back(i + 1);
dfs(_path, n);
_path.pop_back();
}
}
int main(){
int n;
cin >> n;
vector<int> path;
dfs(path, n);
return 0;
}