/**
* week.c
* version:1.0 2006-9-14
* auther:jsp
** w= (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) mod 7
* 在公式中d表示日期中的日數,m表示月份數,y表示年數。
* 注意:在公式中有個與其他公式不同的地方:
* 把一月和二月看成是上一年的十三月和十四月,例:如果是2004-1-10則換算成:2003-13-10來代入公式計算。
*/#include"stdio.h"
struct data;
int isloopyear(struct data *today)
void main()
if(today.month ==2)
if (isloopyear(&today) == 0)
if((today.day > 28) ||(today.day < 1))
if((today.month == 1) || (today.month == 3) ||(today.month == 5)||(today.month == 7)||(today.month == 8)||(today.month == 10)||(today.month == 12))
if((today.day > 31) ||(today.day < 1))
if((today.month == 4) || (today.month == 6) ||(today.month == 9)||(today.month == 11))
if((today.day > 30) ||(today.day < 1))
if((today.month >12) || (today.month < 1))
if(today.month == 2 )
week = (today.day + 2*today.month +3*(today.month + 1)/5+today.year +today.year /4-today.year /100+today.year /400) %7;
week ++;
switch(week)}}
輸入日期求星期的C程式原始碼
week.c version 1.0 2006 9 14 auther jsp w d 2 m 3 m 1 5 y y 4 y 100 y 400 mod 7 在公式中d表示日期中的日數,m表示月份數,y表示年數。注意 在公式中有個與其他公式不同的地方 把一月和二月看成是上一年的十三月和十四月,例 ...
原 輸入日期計算星期
include stdio.h int get week inty,intm,intd a d 2 m 3 m 1 5 y y 4 y 100 y 400 7 基姆拉爾森計算公式,得到的星期幾的整數 returna void printweek intweekday main 這裡的驗證不完善,如果...
輸入兩個日期求相隔的天數
import datetime defis runyear years 判斷乙個年份是否是閏年 return years 4 0and years 100 0or years 400 0def for str data data 格式化字串,將字串轉化為列表 2018 1 1 2018,1,1 re...