Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main( int argc, char *argv[] )
- {
- struct BOARD currentGen;
- struct BOARD nextGen;
- char input[MAX_INPUT_SIZE];
- char title[MAX_INPUT_SIZE];
- int rowSize = 0;
- int colSize = 0;
- while (fgets(input, MAX_INPUT_SIZE, stdin) != NULL)
- {
- strcpy(title, input);
- scanf("%d %d", &rowSize, &colSize);
- fgets(input, MAX_INPUT_SIZE, stdin);
- printf("%s", title);
- printf("%d %d\n", rowSize, colSize);
- for(int r=0; r < rowSize; r++)
- {
- fgets(input, MAX_INPUT_SIZE, stdin);
- printf("%s", input);
- for(int c=0; c < colSize; c++)
- {
- if(input[c] == 'X')
- {
- currentGen.theBoard[r][c] = 'X';
- }
- else
- {
- currentGen.theBoard[r][c] = '.';
- }
- }
- }
- printBoard(rowSize, colSize, currentGen.theBoard);
- }
- return EXIT_SUCCESS;
- }
- void printBoard(int numRows, int numCols, char theBoard[numRows][numCols])
- {
- for(int r=0; r < numRows; r++)
- {
- for(int c=0; c < numCols; c++)
- {
- printf("%c", theBoard[r][c]);
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement