本文整理汇总了C++中TimePoint::getHour方法的典型用法代码示例。如果您正苦于以下问题:C++ TimePoint::getHour方法的具体用法?C++ TimePoint::getHour怎么用?C++ TimePoint::getHour使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimePoint
的用法示例。
在下文中一共展示了TimePoint::getHour方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
int caseId, numEvent, hour, minute, diff;
vector<TimePeriod> events;
char desc[MAX_LEN + 1];
int maxInd, maxMinute;
TimePoint endP(18, 0);
TimePoint startP(10, 0);
TimePeriod endPeriod(endP, endP);
TimePeriod startPeriod(startP, startP);
//freopen("in.txt", "r", stdin);
caseId = 1;
while(scanf("%d", &numEvent) > 0)
{
gets(desc);
events.clear();
events.push_back(startPeriod);
for(int i = 0; i < numEvent; i++)
{
scanf("%d:%d", &hour, &minute);
TimePoint mStart(hour, minute);
scanf("%d:%d", &hour, &minute);
TimePoint mEnd(hour, minute);
events.push_back(TimePeriod(mStart, mEnd));
gets(desc);
}
events.push_back(endPeriod);
numEvent += 2;
sort(events.begin(), events.end());
maxInd = 0;
maxMinute = 0;
for(int i = 0; i < numEvent - 1; i++)
{
diff = events[i].getDistanceInMinute(events[i + 1]);
if(diff > maxMinute)
{
maxMinute = diff;
maxInd = i;
}
}
TimePoint result;
result.getTimePointFromMinute(maxMinute);
printf("Day #%d: the longest nap starts at %d:%02d and will last for ", caseId,
events[maxInd].getEndP().getHour(), events[maxInd].getEndP().getMinute());
if(result.getHour() != 0)
printf("%d hours and ", result.getHour());
printf("%d minutes.\n", result.getMinute());
caseId++;
}
return 0;
}