Latest web development tutorials

C Exercise Example 9

100 cases of classic C language 100 cases of classic C language

Title: required output chess board.

Program analysis: chess board consists of 64 black and white plaid, divided into 8 rows * 8. I used to control row, j column is controlled, according to i + j and changes to control the output black box or white box.

If garbled Please refer to the blog [C Exercise Example 7] solution.

Source Code:

//  Created by www.w3big.com on 15/11/9.
//  Copyright © 2015年 本教程. All rights reserved.
//

#include<stdio.h>

int main()
{
    int i,j;
    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");
    }
    return 0;
}

The above example output is:

100 cases of classic C language 100 cases of classic C language