pascal编程:万年历
展开全部
Program day; Const dt: Array[0..6] OF string = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); Var date, year, month: longint; Function year1(year, month, day: longint): Longint; Var sum, i: longint; Begin sum := 0; for i:=1 TO month-1 Do Begin if i in [1, 3, 5, 7, 8, 10, 12] Then sum := sum + 31; if i in [4, 6, 9, 11] Then sum := sum + 30; if i = 2 Then Begin if ((year mod 4 = 0) And (year mod 100 <> 0)) Or (year mod 400 = 0) Then sum := sum + 29 Else sum := sum + 28; End; End; year1 := sum + day; End; Function week(year, month, day: longint): longint; Begin week := (((year - 1) + (year - 1) div 4 - (year - 1) Div 100 + (year - 1) Div 400) + year1(year, month, day)) Mod 7; End; Begin Writeln('Enter the years '); Readln(year); Writeln('Enter the month: '); Readln(month); Writeln('Enter the date: '); Readln(date); Writeln('Today is ', dt[week(year, month, date)]); Readln; End. 用楼上的公式的第一个算的。。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询