Created
November 14, 2017 09:37
-
-
Save iamvon/7289c972cc01c66d1c201047807c6bbd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Hàm kiểm tra 1 ngày dạng ngày/tháng/năm là ngày thứ mấy trong tuần */ | |
| void DaysOfWeek(int day, int month, int year) | |
| { | |
| int month0 ; | |
| int year0 ; | |
| int dayOfWeek ; | |
| int x ; | |
| year0 = year - (14 - month)/12 ; | |
| x = year0 + year0/4 - year0/100 + year0/400 ; | |
| month0 = month + 12 * ((14 - month)/12) - 2 ; | |
| dayOfWeek = (day + x + 31 * month0/12) % 7 ; | |
| if (dayOfWeek == 0) | |
| cout << "Sunday" ; | |
| else if (dayOfWeek == 1) | |
| cout << "Monday" ; | |
| else if (dayOfWeek == 2) | |
| cout << "Tuesday" ; | |
| else if (dayOfWeek == 3) | |
| cout << "Wednesday" ; | |
| else if (dayOfWeek == 4) | |
| cout << "Thursday" ; | |
| else if (dayOfWeek == 5) | |
| cout << "Friday" ; | |
| else if (dayOfWeek == 6) | |
| cout << "Saturday" ; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hàm kiểm tra 1 ngày dạng ngày/tháng/năm là ngày thứ mấy trong tuần.