1 2 3 4 5 6 7 8 9 10
|
//a combination of the two
const int num_days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};//deal with February..
const char* month_name[] = {"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"};
int day = 153;//form 1 to 365. a copy of the original input.
int month;
for(month = 0; day > num_days[month]; day-=num_days[month], month++);
std::cout << month_name[month] << " " << day;
|