Cod sursa(job #935465)

Utilizator rudarelLup Ionut rudarel Data 3 aprilie 2013 15:10:01
Problema Oras Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.76 kb
#include <stdio.h>
 
int n,a[210][210],i,j,k;
 
int main()
{
    freopen("oras.in","r",stdin);
    freopen("oras.out","w",stdout);
 
    scanf("%d\n",&n);
 
    if (n==4)
    {
        printf("%d\n",-1);
        return 0;
    }
 
    if (n%2)
    {
        i=3;
        a[0][1]=a[1][2]=a[2][0]=1;
    }
    else
    {
        i=6;
        a[0][3]=a[0][4]=a[1][0]=a[1][2]=a[1][3]=a[2][0]=a[2][5]=a[3][2]=a[3][4]=a[3][5]=a[4][1]=a[4][2]=a[5][0]=a[5][1]=a[5][4]=1;
    }
 
    while (i<n)
    {
        a[i][i+1]=1;
        for (j=0;j<i;++j)
            a[j][i]=1,a[i+1][j]=1;
 
        i+=2;
    }
 
    for (i=0;i<n;++i)
    {
        for (j=0;j<n;++j)
            printf("%d",a[i][j]);
        printf("\n");
    }
 
    return 0;
}