#include #include // sans ia et sans gluten const int base_zombies = 3; const int base_humans = 10000; const int max_hours = 100000; const int attack_chance = 80; const int infection_chance = 50; // 50% de chance de se faire infecté si non tué par l'attaque const int death_chance = 20; // 20% de chance de mourir de l'attaque void attack(int *humans, int *zombies) { if (rand() % 100 < death_chance) { *humans = *humans - 1; *zombies = *zombies; } else if (rand() % 100 < infection_chance) { *humans = *humans - 1; *zombies = *zombies + 1; } else { *humans = *humans; *zombies = *zombies; } } void loop(int hour, int humans, int zombies) { int new_humans = humans; int new_zombies = zombies; std:printf("hour: %d| zombies: %d| humans: %d \n", hour, zombies, humans); for (int n = 0; n < zombies; n++) { if (rand() % 100 < attack_chance) { attack(&new_humans, &new_zombies); } } if (new_humans <= 0 || new_zombies <= 0 || hour >= max_hours) { std::printf("finito pipo"); } else { loop(hour+1, new_humans, new_zombies); } } int main() { loop(0, base_humans, base_zombies); return 0; }