Pagini recente » Cod sursa (job #1830194) | Cod sursa (job #1423888) | Cod sursa (job #2344107) | Cod sursa (job #417519) | Cod sursa (job #2939168)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("submultimi.in");
ofstream fout("submultimi.out");
int n,ap[20],st[20];
void Back(int k)
{
for(int x=1;x<=n;x++)
{
st[k]=x;
if(!ap[x] && !(k>1 && x<st[k-1]))
{
ap[x]=1;
for(int j=1;j<=k;j++)
fout << st[j] << " ";
fout << "\n";
Back(k+1);
ap[x]=0;
}
}
}
int main()
{
fin >> n;
Back(1);
return 0;
}