Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > #include <iostream>
- using namespace std;
- int main() {
- int k = 20; // number of years to calculate for
- int pn = 10; // the population of animals for the first year
- double g = 275; // rate of growth
- g = g/100.00;
- double h = 20; // rate of animal death/animals leaving population
- h = h/100.00;
- int M = 100; // carrying capacity of the ecosystem
- /*
- Implementing Verhulst's Formula in C++
- */
- int i;
- int pop;
- for (i = 1; i <= k ; i++)
- {
- pop = (((1 + (g - h)) * pn) - g*(pn*pn)/M) + .5; // the equation
- pn = pop; // this takes the new value of pop and inserts it as pn, to be looped until i <= k
- cout << i << " " << pop << endl;
- }
- return 0;
- }
- 1 35
- 2 96
- 3 88
- 4 102
- 5 75
- 6 116
- 7 37
- 8 100
- 9 80
- 10 112
- 1 25
- 2 70
- 3 120
- 4 33
- 5 94
- 6 90
- 7 98
- 8 86
- 9 92
- 10 70
- int i;
- int pop;
- for (i = 1; i <= k ; i++)
- {
- pop = (((1 + (g - h)) * pn) - g*(pn*pn)/M) + .5; // the equation
- pn = pop; // this takes the new value of pop and inserts it as pn, to be looped until i <= k
- cout << i << " " << pop << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement