From 9e84e86ab3332cf41f2cb3e1eb213506db442c86 Mon Sep 17 00:00:00 2001 From: Leonardo Krambeck <lk19@inf.ufpr.br> Date: Fri, 18 Oct 2019 19:30:27 -0300 Subject: [PATCH] muda input pra int inves de char --- GameOfLife.c | 18 +++++++++++------- gliderPattern.txt | 18 ------------------ 2 files changed, 11 insertions(+), 25 deletions(-) delete mode 100644 gliderPattern.txt diff --git a/GameOfLife.c b/GameOfLife.c index 807445a..6a8bd0e 100644 --- a/GameOfLife.c +++ b/GameOfLife.c @@ -113,20 +113,20 @@ void memoryAlloc (game_t *game) void firstGeneration (game_t *game) { int i=1; - char input = 'i'; - /* arrumar esses diabo de char */ - while ( input != 's' ) + int input = 0; + + while ( input != 3 ) { clear (); printGeneration (game); - printf ("\nDigit [a] to add a live cell, [k] to kill a live cell and [s] to start the game.\n"); - scanf (" %c", &input); + printf ("\nDigit [1] to add a live cell, [2] to kill a live cell and [3] to start the game.\n"); + scanf ("%d", &input); - if (input == 'a') + if (input == 1) addCell (game, &i); - else if (input == 'k') + if (input == 2) removeCell (game, &i); } } @@ -301,6 +301,7 @@ void printGeneration (game_t *game) printf ("Generation: %d\n\n", game->generationNumber); + /* Top grid */ printf (" "); for ( j=1; j <= game->this.cols; j++) if (j % 5 == 0 || j == 1) @@ -311,6 +312,7 @@ void printGeneration (game_t *game) for ( i=1; i <= game->this.rows; i++ ) { + /* Left grid */ if (i % 5 == 0 || i == 1) printf ("%2d", i); else @@ -327,6 +329,7 @@ void printGeneration (game_t *game) printf (" !"); } + /* Right grid */ if (i % 5 == 0 || i == 1) printf ("%2d", i); else @@ -335,6 +338,7 @@ void printGeneration (game_t *game) printf ("\n"); } + /* Bottom grid */ printf (" "); for ( j=1; j <= game->this.cols; j++) if (j % 5 == 0 || j == 1) diff --git a/gliderPattern.txt b/gliderPattern.txt deleted file mode 100644 index 72fa6a3..0000000 --- a/gliderPattern.txt +++ /dev/null @@ -1,18 +0,0 @@ -100 -300000 -15 -17 17 -17 18 -17 19 -18 17 -19 18 -17 12 -17 13 -17 14 -18 12 -19 13 -12 17 -12 18 -12 19 -13 17 -14 18 -- GitLab