1求某年某月某日是星期几
#include <stdio.h> int main() { int y, m, d; scanf("%d%d%d", &y, &m, &d); int M, C, X, ans; M = (m-3) % 12 + 1; C = y / 100;//比如1949年那么C = 19, X = 49; X = y % 100; ans = X + X / 4 + C / 4 - 2 * C + 2 * M +(M + M/7)/2 + M /12 + d % 7; ans %= 7; printf("%d\n", ans); return 0; }
时间: 2024-10-13 08:06:12