1006 Sign In and Sign Out (25)
来源:互联网 发布:sql应用程序在哪里 编辑:程序博客网 时间:2024/05/16 10:23
给你每个人的ID,出入时间,最早进来的人开门,最晚出去的人关门,让你输出开门和关门的人的ID
建一个结构体储存ID和出入时间,然后两次排序,输出最早进来的人的ID和最晚出去的人的ID就行了
#include <cstdio>#include <vector>#include <string>#include <cstring>#include <cstdlib>#include <iostream>#include <algorithm>#define INF 0x3fffffffusing namespace std;struct person{ char id[20]; char intime[20]; char outtime[20];};int cmp1(person a,person b){ return strcmp(a.intime,b.intime)<0;}int cmp2(person a,person b){ return strcmp(a.outtime,b.outtime)>0;}int main(){ int n; person p[1005]; memset(p,0,sizeof(p)); cin>>n; for (int i=0;i<n;i++) { cin>>p[i].id>>p[i].intime>>p[i].outtime; } sort(p,p+n,cmp1); cout<<p[0].id<<' '; sort(p,p+n,cmp2); cout<<p[0].id;}
阅读全文
0 0
- 1006 Sign In and Sign Out (25)
- 1006 Sign In and Sign Out (25)
- 1006 Sign In and Sign Out (25)
- pat 1006 Sign In and Sign Out
- PAT 1006 Sign In and Sign Out
- 1006 Sign in and Sign out
- PAT 1006 Sign In and Sign Out
- PAT 1006 Sign In and Sign Out
- 1006 Sign In and Sign Out
- 1006. Sign In and Sign Out (25)
- PAT1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- HDU1201 18岁的生日
- Spring Boot整合jpa,Shiro进行权限管理
- 用学习曲线 learning curve 来判别过拟合问题
- Libgdx中ScrollPane和Actor事件冲突问题的解决方案
- stm32应用笔记和数据手册
- 1006 Sign In and Sign Out (25)
- 在虚拟机上安装5节点Hadoop分布式集群(HA)-环境准备
- 大量使用oracle DBLINK影响本地数据库的正常操作(过渡使用)
- Android 网络编程
- 重拾nodejs之文件操作
- 使用UIGraphics实现多张图片的合并
- Minor GC、Major GC和Full GC之间的区别
- Java与Kotlin混合开发中的问题
- hibernate 框架开发环境搭建