int getDayNumber(int d, int m, int y) { //retuns the day number
static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
y -= m < 3;
return (y + y / 4 - y / 100 + y / 400 + t[m - 1] + d) % 7;
}
char *getName(int day) { //returns the name of the day
switch (day) {
case 0:return("Sunday");
case 1:return("Monday");
case 2:return("Tuesday");
case 3:return("Wednesday");
case 4:return("Thursday");
case 5:return("Friday");
case 6:return("Saturday");
default:return("Error: Invalid Argument Passed");
}
}
chào a/c
em muốn hỏi chỗ static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; 0 3 2 5 0…(vẫn biết là 1 năm có 12 tháng trong đó có 12 giá trị tượng trưng cho 12 tháng nhưng số liệu đó dựa vào gì mà có được ạ)
em cám ơn