diff options
author | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2023-12-03 06:21:41 +0000 |
---|---|---|
committer | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2023-12-03 06:21:41 +0000 |
commit | 2ff203f3f9a8584e733216c1f459898601cdd0c3 (patch) | |
tree | 7eef1ea3bd500a6e82c6f31b0ceedfa0f1f9c380 /wk1/lab1 | |
parent | 2d0dc9c0a66738dab645b0eed1c8e086edc31dc8 (diff) |
Sat, Dec 2, 2023, 10:21 PM -08:00
Diffstat (limited to 'wk1/lab1')
-rw-r--r-- | wk1/lab1/population.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/wk1/lab1/population.c b/wk1/lab1/population.c index f08b4b9..bef947f 100644 --- a/wk1/lab1/population.c +++ b/wk1/lab1/population.c @@ -3,17 +3,16 @@ int main(void) { - int n = 100/*get_int("Start size: ")*/; - int end = 200/*get_int("End size: ")*/; + int n = get_int("Start size: "); + int end = get_int("End size: "); int year = 0; - //do - //{ - int llamas = n; - n = n + (n/3); - n = n - (n/4); + int llamas = n; + while (llamas <= end) + { + llamas += (n/3); + llamas -= (n/4); + n = llamas; year++; - //} - //while (n <= end); - printf("%i, %i, Years: %i\n", n, end, year); - printf("%i", llamas); + } + printf("Years: %i\n", year); } |