Pagini recente » Cod sursa (job #3253430) | Cod sursa (job #16962) | Cod sursa (job #1847058) | Cod sursa (job #2161867) | Cod sursa (job #1007123)
#include <fstream>
using namespace std;
ifstream f("permutari.in");
ofstream g("permutari.out");
int x,k,n,i;
int st[9],ap[10];
void tipar(int k)
{
for(i=1;i<=k;++i) g<<st[i]<<" ";
g<<'\n';
}
void back(int k)
{
int x;
for(x=1;x<=n;++x)
{
if (ap[x]==0)
{
st[k]=x;
ap[x]=1;
if(k==n) tipar(k);
else back(k+1);
ap[x]=0;
}
}
}
int main()
{
f>>n;
back(1);
return 0;
}