// Tim chính xác thu theo ngày tháng nam dã biêt // // http://en.wikipedia.org/wiki/Julian_day#Calculation // int* get_day(int day, int month, int year) { int JMD; JMD = (day + ((153 * (month + 12 * ((14 - month) / 12) - 3) + 2) / 5) + (365 * (year + 4800 - ((14 - month) / 12))) + ((year + 4800 - ((14 - month) / 12)) / 4) - ((year + 4800 - ((14 - month) / 12)) / 100) + ((year + 4800 - ((14 - month) / 12)) / 400) - 32045) % 7; //cout << JMD; const int* weekday[] = { 2, 3, 4, 5, 6, 7, 8 }; return weekday[JMD]; } void DayClose(int k, Date d1, Date d2) { int i = d1.day; if (d1.month == 1 || d1.month == 3 || d1.month == 5 || d1.month == 7 || d1.month == 8 || d1.month == 10 || d1.month == 12) { if (d1.month < d2.month) { for (i;i < 31;i++) { if (get_day(i, d1.month, d1.year) == k) { cout << "that day" << endl; cout << d1.year << " " << d1.month << " " << i; } if (i == 31) { d1.month++; i = 1; } } } } else if (d1.month == 4 || d1.month == 6 || d1.month == 9 || d1.month == 12) { if (d1.month < d2.month) { for (i;i < 30;i++) { if (get_day(i, d1.month, d1.year) == k) { cout << "that day" << endl; cout << d1.year << " " << d1.month << " " << i; } if (i == 30) { d1.month++; i = 1; } } } } else if (d1.month == 2) { if (d1.month < d2.month) { for (i;i < 28;i++) { if (get_day(i, d1.month, d1.year) == k) { cout << "that day" << endl; cout << d1.year << " " << d1.month << " " << i; } if (i == 28) { d1.month++; i = 1; } } } } }