1006.Sign In and Sign Out

来源:互联网 发布:武汉mac口红专柜在哪里 编辑:程序博客网 时间:2024/04/28 15:35

【题意】

比较登进登出的时间记录并且输出最早登进、最晚登出的ID


【思路】
按题意直接写即可

#include <iostream>#include <string>#include <vector>#include <cstdio>using namespace std;int main(){int m;string id;int time1,time2;vector<string> ids;int earliestIndex,latestIndex;int earliestTime,latestTime;earliestTime = 24*3600-1;latestTime = 0;cin >> m;for(int i=0; i<m; i++){cin >> id;int hh,mm,ss;scanf("%d:%d:%d", &hh, &mm, &ss);time1 = hh*3600+mm*60+ss;scanf("%d:%d:%d", &hh, &mm, &ss);time2 = hh*3600+mm*60+ss;ids.push_back(id);if(time1<earliestTime){earliestIndex = i;earliestTime = time1;}if(time2>latestTime){latestIndex = i;latestTime = time2;}}cout << ids.at(earliestIndex) << " " << ids.at(latestIndex);system("pause");return 0;}


0 0
原创粉丝点击