开发者

Days to Next Thursday

开发者 https://www.devze.com 2023-02-19 18:31 出处:网络
I m trying to write a code in C on caclulating days until next thursday. I need help, using this paragrah.

I m trying to write a code in C on caclulating days until next thursday. I need help, using this paragrah. http://en.wikipedia.org/wiki/Doomsday_rule#Finding_the_day_of_the_week_of_a_given_calendar_date

any ideas on how i should apporac开发者_如何学运维h it, and rough guideline


Separate your problem in smaller problems.

When you feel like a smaller problem is small enough to solve, solve that problem.

For instance: your master problem is "using the technique described in the wikipedia article calculate how many days are there till next Thursday".

Problems small enough to make into a function:

  • calculate (or lookup) a year's doomsday (Monday for 2011) yeardoomsday(2011)
  • calculate (or lookup) a month doomsday (7 for March) monthdoomsday(2011, 3)
    calls yeardoomsday(2011) somewhere inside the function
  • ...
0

精彩评论

暂无评论...
验证码 换一张
取 消