This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:cprog:fall2024:projects:mmf0 [2024/09/24 16:19] – [Edge case: leap years] tkastne1 | notes:cprog:fall2024:projects:mmf0 [2024/09/29 03:52] (current) – [If it is a leap year subtract 1 more] mwinter4 | ||
---|---|---|---|
Line 1: | Line 1: | ||
======MMF0====== | ======MMF0====== | ||
+ | In this project we are to determine, given a year as input, which day of the week the January 1st of that year falls on. We can determine this with an algorithm known as <wrap hi> | ||
=====Process===== | =====Process===== | ||
Line 11: | Line 11: | ||
</ | </ | ||
+ | The ampersand above is necessary to assign the inputted value to our variable. The ampersand tells the fscanf function where our variable is stored in memory, so that we may access and modify the value based on the input we receive from the verify script. | ||
====Obtain the last two digits of this input value==== | ====Obtain the last two digits of this input value==== | ||
+ | To obtain the last 2 digits of our inputted year, we can take our year and mod (%) it by 100. Because we are using Zeller' | ||
====Quarter the value==== | ====Quarter the value==== | ||
====Add quartered value back to two digit year==== | ====Add quartered value back to two digit year==== | ||
====Subtract best fitting multiple of seven==== | ====Subtract best fitting multiple of seven==== | ||
+ | To subtract the best fitting multiple of seven the % operator can be used | ||
+ | * Do note that % is the remainder operator and not a modulo operator | ||
+ | * Modulo and remainder are primarily the same but they handle negative numbers differently | ||
====If it is a leap year subtract 1 more ==== | ====If it is a leap year subtract 1 more ==== | ||
+ | However, if we are using Zeller' | ||
====Look up day in table==== | ====Look up day in table==== | ||