Article directory
topic
Output the chess board.
ideas
Use i to control the row, j to control the column, according to the change of the sum of i+j to control the output black square or white square.
Note that the numbers 128 to 255 are extended codes and are not originally used for display. Change the code page of the console that executes this program to 437.
answer
#include <stdio.h>
#include <windows.h>
int main()
{
int i,j;
SetConsoleOutputCP(437);
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
if((i+j)%2==0)
{
printf("%c%c",219,219);
}
else
{
printf(" ");
}
}
printf("\n");
}
}