00:01
Okay, so here we want to intake three integers and produce the maximum, medium, mean, and minimum of them, right? so i'm just going to call this 4ms, 4 max, median, mean, and minimum.
00:19
That's our procedure name, and it'll intake just the three integers, right? so we just have a1, a2, and a3, and they could be in any order.
00:34
All right, so the first thing we want to do is initially define our minimum and maximum, right? so we're just going to set them each to the first element in our list as a1 and a2, and then we'll adjust them accordingly if necessary.
00:58
So we'll initialize those.
01:01
And so first, let's say we can start with the minimum, but you can start with the maximum.
01:06
This order is not too important.
01:09
So say for i, our index running from 2 to 3, so just for the other two elements, let's say if a .i is less than the minimum, then we'll reset our minimum to that value.
01:48
So basically if a2 or a3 is less than a1, it gets adjusted here.
01:57
Okay, and so while we are at it, we can do the same thing with the maximum, right? so if you could put this in a separate four loop as well, but if a i is greater than the maximum, then well, same thing, then we'll set our maximum, reset it to a i.
02:34
Okay, so now we have found our minimum and maximum.
02:39
Now the mean is the average.
02:45
So for that, we don't need any loops.
02:50
We can just do a little arithmetic.
02:52
So we'll just set the mean identically equal to the sum of a1 plus a2 plus a3.
03:04
You might even have a function for some, but with just three elements, sometimes just writing it out is just as simple and quick...