--Originally published at Loading…
Hi! I know it pass a long time without posting anything, sorry I’m in that point of the semester trying to save it.
And I know maybe this post would be more useful the last week, before the partial, but… I hope it could help you.
1. Distance again.
Actually I’ve already explain this code, and I do the same in this quiz, so I’m not going to explain this one, but here is my code:
2. T’s pyramid
This one was kind of difficult because one of my functions was wrong, but technically it’s veryyyy easy.
I only use the library <iostream>, but I used two functions. The first one was for print the T in each line, for this I used an if and a for, which simply is adding one T in each line of the pyramid. The second function is for print how many lines must have the pyramid, so I use two for, one to increase f (fila) while it’s smaller than n(the number that the user enter). And the other one to decrease f, when it is the same as n and until f is 1.
This one I’ve already explained too, so like the first one, I’m not going to explain it. The only difference is that I made this code more simply like the one that is in the link.
4. Average list
This one was kind of easy. First I established the libraries <iostream> and <cmath> and as always put the using namespace std;. Then, I created a float function named promedio_lista that receives the sum and returns the prom. Next, in my int main I established two kind of variables, in the float I put the array cal (this ‘save’