Pagini recente » Cod sursa (job #1623013) | Cod sursa (job #1143409) | Cod sursa (job #2224446) | Cod sursa (job #509271) | Cod sursa (job #1213985)
//////////////nu pot sa inteleg de ce nu e bine pe N=4
//////////////0101
//////////////0011
//////////////1000
//////////////0010
//////////////exemplul de sus e bun pentru N=4 :-???
#include <cstdio>
using namespace std;
#define NMAX 250
int N,i,j;
bool M[NMAX][NMAX];
int main()
{
freopen("oras.in","r",stdin);
freopen("oras.out","w",stdout);
scanf("%d",&N);
if (N==4)
{
printf("-1\n");
return 0;
}
if (!(N&1))
{
M[1][2]=1;
M[2][3]=1;
M[3][1]=1;
M[4][5]=1;
M[5][6]=1;
M[6][4]=1;
M[1][4]=1;
M[2][6]=1;
M[3][5]=1;
M[4][2]=1;
M[5][1]=1;
M[6][3]=1;
M[4][3]=1;
M[5][2]=1;
M[6][1]=1;
for (i=8;i<=N;i+=2)
{
for (j=1;j<=i-2;++j)
{
M[j][i-1]=1;
M[i][j]=1;
}
M[i-1][i]=1;
}
}
else
{
M[1][2]=1;
M[2][3]=1;
M[3][1]=1;
for (i=5;i<=N;i+=2)
{
for (j=1;j<=i-2;++j)
{
M[j][i-1]=1;
M[i][j]=1;
}
M[i-1][i]=1;
}
}
for (i=1;i<=N;++i,printf("\n"))
for (j=1;j<=N;++j)
printf("%d",M[i][j]);
return 0;
}