Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* A program to print a checker pattern */
- /* g++ -ansi -Wall checker.cpp -o checker */
- #include <stdio.h>
- #define SIZE 100
- void initImage(char image[SIZE][SIZE], int pWidth, int pHeight);
- int main()
- {
- int pWidth = 5, pHeight = 5;
- char myArray[SIZE][SIZE];
- initImage(myArray, pWidth, pHeight);
- return 0;
- }
- void initImage(char image[SIZE][SIZE], int pWidth, int pHeight)
- {
- int i, j;
- // Initialise the checker array by rows and collumns, currently not functional
- for (i=0; i<SIZE; i++)
- {
- for (j=0; j<SIZE; j++)
- {
- if (i<pHeight || i>=pHeight*2)
- {
- image[i][j] = '.';
- }
- if (j<pWidth || j>=pWidth*2)
- {
- image[i][j] = '*';
- }
- if ((j>=pWidth*2 && i>=pHeight))
- {
- image[i][j] = '&';
- }
- }
- }
- // Print the array just to test it's correct
- for (i=0; i<pHeight*3; i++)
- {
- for (j=0; j<pWidth*3; j++)
- {
- printf("%c", image[i][j]);
- }
- printf("\n");
- }
- }
Add Comment
Please, Sign In to add comment