1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| #include <iostream>
#include <vector>
#include <tuple>
#include <list>
using namespace std;
using record_t = std::tuple< std::vector<int>, std::vector<int>, int, int, int>;
void bbf(list<record_t>& to_process) {
// Extract data
std::vector<int> chchaine, bububuffer;
int lonlongueur, inind, compt;
tie(chchaine, bububuffer, lonlongueur, inind, compt) = to_process.front();
// Do process
if (inind>=lonlongueur) {
for (int i : bububuffer) cout << i;
cout << endl;
return;
}
for (size_t ii=0; ii < chchaine.size(); ++ii) {
bububuffer[inind] = chchaine[ii];
to_process.emplace_back(record_t(chchaine, bububuffer,lonlongueur,inind+1, compt));
//bbf(chchaine,bububuffer,lonlongueur,inind+1, compt);
}
}
int main(int argc, char* argv[])
{
vector<int> tatable (3,0);
for (size_t i=0; i < tatable.size(); ++i) tatable[i] = static_cast<int>(i+1);
int taille_tatable = tatable.size();
vector <int> buffer (taille_tatable,0);
int compt =0;
list<record_t> record_to_process;
for(size_t i=1; i<=taille_tatable; ++i) {
record_to_process.emplace_back(record_t(tatable, buffer, i, 0, compt));
}
while (record_to_process.size()) {
bbf(record_to_process);
record_to_process.pop_front();
if (false) break; // Remplacer false par ta condition d'arrêt
}
return 0;
} |
Partager