Pagini recente » Cod sursa (job #1830421) | Cod sursa (job #507664) | Cod sursa (job #2020675) | Cod sursa (job #507591)
Cod sursa(job #507591)
#include <stdio.h>
#define NMAX 215
int a[NMAX][NMAX];
int n;
inline int mod(int x){
if(x <= 0) return x += n;
return x;
}
inline int dist(int x, int y){
if(y-x > 0) return y-x;
return y-x + n;
}
int main(){
freopen("oras.in", "r", stdin);
freopen("oras.out", "w", stdout);
scanf("%d", &n);
if(n == 4){
printf("-1\n");
return 0;
}
for(int i = 1; i < n; ++i)
a[i][i+1] = 1;
a[n][1] = 1;
for(int i = 1; i <= n; ++i)
a[i][mod(i-2)] = 1;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
if(i != j)
if(dist(i, j) >= 3 && dist(i, j) % 2 == 1) a[i][j] = 1;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= n; ++j)
printf("%d", a[i][j]);
printf("\n");
}
return 0;
}