Advertisement
Guest User

chess table

a guest
Sep 25th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. const int TABLE_SIZE = 8;
  4.  
  5. int main() {
  6.     printf("Size of the table: ");
  7.     int unit;
  8.     scanf("%d", &unit);
  9.  
  10.     const int real_size = unit * TABLE_SIZE;
  11.     const int modulus = unit * 2;
  12.  
  13.     for (int row = 0; row < real_size; ++row) {
  14.         for (int column = 0; column < real_size; ++column)
  15.             if ((row % modulus < unit) ^ (column % modulus < unit))
  16.                 printf(".");
  17.             else
  18.                 printf("X");
  19.  
  20.         printf("\n");
  21.     }
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement