• A1006. Sign In and Sign Out


     

    基本思路

    • 搞一个结构体做记录,然后比较每个记录的时间先后,输出最早进入和最后离开的人
    #include <bits/stdc++.h>
    
    using namespace std;
    
    struct notes{
    	char id[20];
    	int hh, mm, ss; // 
    }tmp, earliest, lastest;
    
    bool earlier(notes object, notes target){
    	if(object.hh != target.hh){
    		return target.hh < object.hh;
    	}
    	if(object.mm != target.mm){
    		return target.mm < object.mm;
    	}
    	return target.ss < object.ss;
    }
    int main(int argc, char* argv[]) {
    	char a;
    	int n;
    	cin >> n;
    	earliest.hh = 0, earliest.mm = 0, earliest.ss = 0;
    	lastest.hh = 24, lastest.mm = 60, lastest.ss = 60;
    	for(int i = 0; i < n; i++){
    		// 用字符 a 接收 ":" 
    		cin >> a >> tmp.hh >> a >> tmp.mm >> a >> tmp.ss;
    		if(earlier(earliest, tmp)){
    			earliest = tmp;		
    		}
    		cin >> a >> tmp.hh >> a >> tmp.mm >> a >> tmp.ss;
    		if(earlier(lastest, tmp)){
    			lastest = tmp;
    		}
    	}
    	cout << earliest.id << ' ' << lastest.id << endl;
    	return 0;
    }
  • 相关阅读:
    Javascript异步编程的4种方法(阮一峰)
    vue 要点
    npm指南
    http请求状态及其含义表
    IOS 7层协议
    js模块化
    UITouch触摸事件
    UIGestureRecognizer手势识别
    UISegmentControl 、UIStepper
    UINavigationController
  • 原文地址:https://www.cnblogs.com/YC-L/p/12319834.html
Copyright © 2020-2023  润新知