Cod sursa(job #81143)

Utilizator anna_bozianuBozianu Ana anna_bozianu Data 31 august 2007 16:59:02
Problema Oras Scor 55
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include<stdio.h>
long int n,i,j;
char a[202][202];
int main()
{
	FILE *f,*g;f=fopen("oras.in","r");g=fopen("oras.out","w");
	fscanf(f,"%ld",&n);
	if(n==4){fprintf(g,"-1\n");fcloseall();return 0;}
	if(n%2)
	{ for(i=0;i<n;i++)
	   {
		if(i%2)for(j=0;j<i;j++){a[i][j]='0';a[j][i]='1';}
		else { for(j=0;j<i;j++){a[i][j]='1';a[j][i]='0';}
		       a[i][i-1]='0';a[i-1][i]='1';}
		a[i][i]='0';
	    }
	    for(i=0;i<n;i++)fprintf(g,"%s\n",a[i]);
	    fcloseall();
	    return 0;
	}
	else
	for(i=0;i<n;i++)fprintf(g,"%s\n",a[i]);
	fcloseall();
	return 0;
}