#include<fstream>
using namespace std;
ifstream fin("date.in");
ofstream fout("date.out");
struct muchie
{
int i,j;
};
int x[100000],n,m,nr=0;
muchie M[100000];
void Write()
{ int i,j;
nr++;
fout<<"solutia numarul "<<nr<<"\n";
fout<<"vectorul muchiilor:\n";
for(i=1;i<=m;i++) if(x[i]) fout<<M[i].i<<" "<<M[i].j<<"\n";
fout<<"matricea de adiacenta:\n";
int A[100][100]={0};
for(i=1;i<=m;i++)
if(x[i]) A[M[i].i][M[i].j]=A[M[i].j][M[i].i]=1;
for(i=1;i<=n;i++)
{ for(j=1;j<=n;j++)
fout<<A[i][j]<<" ";
fout<<"\n";
}
}
void Sub(int k,int n)
{ for(int i=0;i<=1;i++)
{
x[k]=i;;
if(k==n) Write();
else Sub(k+1,n);
}
}
int main()
{ int i,j,k=1;
fin>>n;
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++)
{
M[k].i=i; M[k].j=j; k++;
}
m=n*(n-1)/2;
Sub(1,m);
fin.close();
fout.close();
return 0;
}
|