#include
using namespace std;
void NextMinute(int *nYear,int *nMonth,int *nDate,int *nHour,int *nMinute,int
*nSecond)
{
int nDays;
(*nSecond)++;
if(*nSecond >= 60)
{
*nSecond = 0;
(*nMinute)++;
if(*nMinute >= 60)
{
*nMinute = 0;
(*nHour)++;
if(*nHour >= 24)
{
*nHour = 0;
(*nDate)++;
switch(*nMonth)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
nDays = 31;
break;
case 2:// 判断闰年
if(*nYear%400 == 0 || *nYear%100 != 0 && *nYear%4 == 0)
{
nDays = 29;
}
else
{
nDays = 28;
}
break;
default:
nDays = 30;
break;
}
if(*nDate > nDays)
{
*nDate = 1;
(*nMonth)++;
if(*nMonth > 12)
{
*nMonth = 1;
(*nYear)++;
}
}
}
}
}
}
void main()
{
int nYear=2004, nMonth=12, nDate=31, nHour=59, nMinute=59, nSecond=59;
NextMinute(&nYear, &nMonth, &nDate, &nHour, &nMinute, &nSecond);
printf("The result:%d-%d-%d %d:%d:%d", nYear, nMonth, nDate, nHour, nMinute, nSecond);
}
阅读(1901) | 评论(0) | 转发(0) |