Cod sursa(job #1584939)
Utilizator | Data | 30 ianuarie 2016 16:53:28 | |
---|---|---|---|
Problema | Submultimi | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.63 kb |
#include <fstream>
using namespace std;
ifstream fin("submultimi.in");
ofstream fout("submultimi.out");
int v[30],uz[30];
void afisare(int nr)
{
for(int i=1;i<=nr;i++) fout<<v[i]<<" ";
fout<<"\n";
}
void gen(int k,int nr,int n)
{
if(k==nr+1) afisare(nr);
else
{
for(int i=1;i<=n;i++)
{
if(uz[i]==0)
{
v[k]=i;
uz[i]=1;
gen(k+1,nr,n);
uz[i]=0;
}
}
}
}
int main()
{
int n,i;
fin>>n;
for(i=1;i<=n;i++) gen(1,i,n);
}