Pagini recente » Cod sursa (job #1448825) | Cod sursa (job #2126966) | Cod sursa (job #2667216) | Cod sursa (job #2372161) | Cod sursa (job #1637254)
#include <fstream>
using namespace std;
int n;
bool v[10];
int x[10];
ofstream g("permutari.out");
void bkt(int i) {
for(int j = 1; j <= n; j ++) {
if(!v[j]) {
x[i] = j; v[j] = true;
if(i == n) {
for(int o = 1; o <= n; o ++) g << x[o] << " ";
g << "\n";
}
else bkt(i + 1);
v[j] = false;
}
}
}
int main()
{
ifstream f("permutari.in");
f >> n;
bkt(1);
return 0;
}