Skip to content

Instantly share code, notes, and snippets.

@nanpuyue
Created March 13, 2014 15:10
Show Gist options
  • Save nanpuyue/9530266 to your computer and use it in GitHub Desktop.
Save nanpuyue/9530266 to your computer and use it in GitHub Desktop.
输入日期计算星期
program day;
var y,a,b,c,e,f:longint; m,d:word;
begin write('输入日期(年月日,以空格隔开):'); read(y,m,d);
a:=y div 4-y div 100+y div 400;
if (((y mod 4=0) and (y mod 100<>0)) or (y mod 400=0)) and ((m=1) or (m=2)) then b:=1 else b:=0;
c:=y+a+d-b;
case m of
1,10:e:=c+6;
2,3,11:e:=c+2;
4,7,12:e:=c+5;
5:e:=c;
6:e:=c+3;
8:e:=c+1;
9:e:=e+4;
else writeln ('错误'); end;
f:=e mod 7;
writeln('这天是星期',f,'( 0 表示星期日)');
end.
@nanpuyue
Copy link
Author

nanpuyue commented Jul 2, 2016

这是高中学编程后写的第一个程序。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment