Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. int main( int argc, char *argv[] )
  2. {
  3. struct BOARD currentGen;
  4. struct BOARD nextGen;
  5. char input[MAX_INPUT_SIZE];
  6. char title[MAX_INPUT_SIZE];
  7. int rowSize = 0;
  8. int colSize = 0;
  9.  
  10.  
  11. while (fgets(input, MAX_INPUT_SIZE, stdin) != NULL)
  12. {
  13. strcpy(title, input);
  14.  
  15. scanf("%d %d", &rowSize, &colSize);
  16.  
  17. fgets(input, MAX_INPUT_SIZE, stdin);
  18.  
  19. printf("%s", title);
  20. printf("%d %d\n", rowSize, colSize);
  21.  
  22. for(int r=0; r < rowSize; r++)
  23. {
  24.  
  25. fgets(input, MAX_INPUT_SIZE, stdin);
  26. printf("%s", input);
  27. for(int c=0; c < colSize; c++)
  28. {
  29. if(input[c] == 'X')
  30. {
  31. currentGen.theBoard[r][c] = 'X';
  32. }
  33. else
  34. {
  35. currentGen.theBoard[r][c] = '.';
  36. }
  37. }
  38. }
  39.  
  40. printBoard(rowSize, colSize, currentGen.theBoard);
  41.  
  42. }
  43.  
  44.  
  45.  
  46.  
  47.  
  48. return EXIT_SUCCESS;
  49. }
  50.  
  51. void printBoard(int numRows, int numCols, char theBoard[numRows][numCols])
  52. {
  53. for(int r=0; r < numRows; r++)
  54. {
  55. for(int c=0; c < numCols; c++)
  56. {
  57. printf("%c", theBoard[r][c]);
  58. }
  59. printf("\n");
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement