/ * A simulated life reproduced program * / # include
Float random () / * The number generation function adds the time variable purpose to strengthen its randomness * / {float aa; INT I, J; Struct Time T; GetTime (& T); i = (t.ti_min t .ti_Hour T.TI_SEC T.TI_HUND)% 3; for (j = 0; j
Main () {struct geti / * is used to record individual information * / {Int sex; / * Gender 0: female, 1: Male, 2: Non-record * / int Age; / * age (1-100) * / int Food; / * No number of food cycles (0-4) * / int x; / * Individual x coordinate (1-200) * / int y; / * Individual Y coordinate (1-200) * / int flag; / * Validity of individual records 0: Invalid, 1: effective * /} people [mp];
INT CYCLE = 40; / * Update the number of foods, do not use this variable after improvement * / int popf = 350, POPM = 0, POPF = 0, MPOP = 0; / * The number of initial population * / int map [mx] [m]; / * Record disk number food quantity * / int DRIVER = VGA, Mode = Vgahi; char text1 [20] = "maxpopulation:.", text2 [5] = "man:", text3 [7] = "Woman:"; / * Statistics String * /
INT ZHOUQI = CYCLE-1, J, K, L, I; / * Time Variables and Circulating Variables * / FLOAT Suiji, Tianzai = 0; / * Take the Tariff and Disaster Variables * / RegisterBgidriver; Initgraph (& Driver, & Mode , "// tc"); / * Graphical interface initialization * / for (i = 0; i / * Population initialization * / for (j = 0; j IF (ZHOUQI% cycle == 0) {/ * update food, and initializes i * / cycle = random () * 100 10; for (j = 0; j IF (map [people [j] .x] [people [j] .y] == 0) {setFillStyle (1,0); bar (19 2 * people [j] .x, 19 2 * people [ J, 19 2 * people [j] .x 1, 19 2 * people [j] .y 1);} else {setfillstyle (1, 1); bar (19 2 * people [ J] .x, 19 2 * people [j] .y 19 2 * people [j] .x 1,19 2 * people [j] .y 1);} suiji = random (); / * Mobile * / if (SUIJI <= 0.25) {if (People [J] .x / * Breeding calculation * / if (People [J] .age <45 && people [j] .age> 18) for (k = 0; k }