当前位置: 首页>>代码示例>>C++>>正文


C++ TimePoint::getMinute方法代码示例

本文整理汇总了C++中TimePoint::getMinute方法的典型用法代码示例。如果您正苦于以下问题:C++ TimePoint::getMinute方法的具体用法?C++ TimePoint::getMinute怎么用?C++ TimePoint::getMinute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TimePoint的用法示例。


在下文中一共展示了TimePoint::getMinute方法的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;
}
开发者ID:HMLONG,项目名称:uva-online-judge-solutions,代码行数:62,代码来源:UVA10191.cpp


注:本文中的TimePoint::getMinute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。