1990年1月1日 是星期一,
输入:1990 1 1 输出 monday
输入:2013 9 17 输出 tuesday
#include<cstdio> #include<cstring> char *weeks[]={"sunday","monday","tuesday","wednesday","thursday","friday","saturday"}; void zeller(int y,int m,int d){ if(m<=2) { y--; m+=12; } int c=y/100; y=y%100; int w=y+y/4+c/4-2*c+(26*(m+1)/10)+d-1; while(w<0)w+=7; printf("%s\n",weeks[w%7]); } int main(int argc, char *argv[]) { int y,m,d; while(~scanf("%d %d %d",&y,&m,&d)) { zeller(y , m , d); } return 0; }
时间: 2024-10-22 01:29:47