当我啜饮我的啤酒并感到无聊时,我就会想到这个问题。如何使用C,Java等流行的编程语言有效地找到下一个第13个星期五 C#,Python,Perl,PHP甚至是Lisp,ALGOL等。哪些代码看起来最简洁,更智能?
答案 0 :(得分:1)
C#:
DateTime date = DateTime.Now; // as today is 13th. If system date changes then hardcode date.
while (date < <Some date in the future you want to report to>)
{
date = date.AddMonths(1);
if (date.DayOfWeek == DayOfWeek.Friday)
System.Console.PrintLine(date.ToString());
}