TC simulates life breeding

xiaoxiao2021-03-05  22

/ * A simulated life reproduced program * / # include / * This program is to be strengthened in: food production rather than natural existence! * / # Include #include #include #define MX 60 / * Maximum value of national horizontal * / # Define my 60 / * Maximum set of longitudinal width * / # define MP 3600 / * Country's largest population restrictions * /

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 15) / * This death condition It also needs to be strengthened (currently considering population, disasters, age and food) * / {/ * Start death operation * / if (map [people [j] .x] [people [j] .y] == 0) {setFillStyle (1, 0); BAR (19 2 * people [J] .x, 19 2 * people [j] .y, 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);} if (people [j] .sex == 0) POPF- = 1; ELSE POPM- = 1; population- = 1; people [J ] .SEX = 2; people [j] .age = 0; People [j] .food = 0; people [j] .x = 0; people [j] .y = 0; people [j] .flag = 0;} else {/ * non-death operation * // * eat food Calculate * / if (Map [people [j] .x - 1] [people [j] .y - 1] == 0 || people [j] .food <9) people [j] .food = 1; / * Considering human civilization and social morality, individuals reserved food for others * / else {people [J] .food = 0; MAP [people [j] .x - 1] [people [j] .y - 1] - = 1;}

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 1) people [j] .x- = 1;} else if (SUIJI <= 0.75) {IF (people [j] .y 1) people [j ]y- = 1;} setfillstyle (1, 3 * people [j] .SEX 2); bar (19 2 * people [j] .x, 19 2 * people [j] .y, 19 1 2 * people [j] .x, 19 2 * people [j] .y 1);

/ * Breeding calculation * / if (People [J] .age <45 && people [j] .age> 18) for (k = 0; k 18 && people [k] .age <45) / * age restriction * / {/ * Start reproduction * / For (l = 0; l

}

转载请注明原文地址:https://www.9cbs.com/read-35876.html

New Post(0)