initialise variables with non 0 value
This commit is contained in:
7
main.cpp
7
main.cpp
@@ -19,16 +19,13 @@ void attack(int humans, int zombies, int *new_humans, int *new_zombies) {
|
|||||||
} else if (rand() % 100 < infection_chance) {
|
} else if (rand() % 100 < infection_chance) {
|
||||||
*new_humans = humans - 1;
|
*new_humans = humans - 1;
|
||||||
*new_zombies = zombies + 1;
|
*new_zombies = zombies + 1;
|
||||||
} else {
|
|
||||||
*new_humans = humans;
|
|
||||||
*new_zombies = zombies;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(int hour, int humans, int zombies) {
|
void loop(int hour, int humans, int zombies) {
|
||||||
|
|
||||||
int new_humans;
|
int new_humans = humans;
|
||||||
int new_zombies;
|
int new_zombies = zombies;
|
||||||
|
|
||||||
std:printf("hour: %d| zombies: %d| humans: %d \n", hour, zombies, humans);
|
std:printf("hour: %d| zombies: %d| humans: %d \n", hour, zombies, humans);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user