Please check this loop:
for (unsigned int i = loopDay; i < day; i++) { ... }
the
i
variable isn't used inside the loop body, so you're doing the same thing n-times. I think you should changem1[day][...]
withm1[i][...]
(same form5
andm25
).About the
loopDay
variable:while (dayCount == 0) { loopDay = day - 1; dayCount++; }
I suppose what you mean is:
if (dayCount == 0) loopDay = day; ++dayCount;
In this way
loopDay
stores the first day seen (the first day you'll print in the for loop). Considering thatdayCount
isn't referenced in other points of the source code you could get rid of it and write:if (time == 0) loopDay = day;
Now you have to change the the upper limit in the for loop: the last day you have seen must be included so
< day
must be<= day
.
There are other things to change but this is a starting point.