#include<stdio.h>
int main()
{
int i,j,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(i%2!=0&&j%2!=0)
{
printf("1");
}
else if(i%2==0&&j%2==0)
{
printf("1");
}
else
{
printf("0");
}
}
printf("\n");
}
}
input:
5
output:
10101
01010
10101
01010
10101
int main()
{
int i,j,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(i%2!=0&&j%2!=0)
{
printf("1");
}
else if(i%2==0&&j%2==0)
{
printf("1");
}
else
{
printf("0");
}
}
printf("\n");
}
}
input:
5
output:
10101
01010
10101
01010
10101
No comments:
Post a Comment