Pagini recente » Cod sursa (job #1045171) | Cod sursa (job #1430202) | Cod sursa (job #2514386) | Cod sursa (job #150498) | Cod sursa (job #2233406)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("permutari.in");
ofstream g("permutari.out");
int N,st[8];
int Valid(int k)
{
int i;
for(i=1;i<=k-1;i++)
if(st[i]==st[k])
return 0;
return 1;
}
int Afisare (int N)
{
int i;
for(i=1;i<=N;i++)
g<<st[i]<<" ";
g<<endl;
}
void Per(int N)
{
int i,k=1;
st[k]=0;
while(k>0)
if(k==N+1)
{
Afisare(N);
k--;
}
else
if(st[k]<N)
{
st[k]++;
if(Valid(k)==1)
{
k++;
st[k]=0;
}
}
else
k--;
}
int main()
{f>>N;
Per(N);
cout << "Hello world!" << endl;
return 0;
}