Guest User

Untitled

a guest
Jun 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. /* A program to print a checker pattern */
  2. /* g++ -ansi -Wall checker.cpp -o checker */
  3.  
  4. #include <stdio.h>
  5. #define SIZE 100
  6.  
  7. void initImage(char image[SIZE][SIZE], int pWidth, int pHeight);
  8.  
  9. int main()
  10.  
  11. {
  12. int pWidth = 5, pHeight = 5;
  13. char myArray[SIZE][SIZE];
  14. initImage(myArray, pWidth, pHeight);
  15.  
  16. return 0;
  17. }
  18.  
  19.  
  20.  
  21. void initImage(char image[SIZE][SIZE], int pWidth, int pHeight)
  22.  
  23. {
  24. int i, j;
  25.  
  26. // Initialise the checker array by rows and collumns, currently not functional
  27. for (i=0; i<SIZE; i++)
  28. {
  29. for (j=0; j<SIZE; j++)
  30. {
  31. if (i<pHeight || i>=pHeight*2)
  32. {
  33. image[i][j] = '.';
  34. }
  35. if (j<pWidth || j>=pWidth*2)
  36. {
  37. image[i][j] = '*';
  38. }
  39. if ((j>=pWidth*2 && i>=pHeight))
  40. {
  41. image[i][j] = '&';
  42. }
  43.  
  44. }
  45. }
  46.  
  47. // Print the array just to test it's correct
  48. for (i=0; i<pHeight*3; i++)
  49. {
  50. for (j=0; j<pWidth*3; j++)
  51. {
  52. printf("%c", image[i][j]);
  53. }
  54. printf("\n");
  55. }
  56. }
Add Comment
Please, Sign In to add comment