---
title: "PAT 1006 Sign In and Sign Out"
author: "J2EE大鸟"
date: "2013-03-02T12:08:32Z"
tags: []
categories: ["编程语言"]
slug: "pat-1006-sign-in-and-sign-out"
draft: false
lastmod: "2013-03-01T20:57:10Z"
id: 1820118
url: "https://benworld.iteye.com/blog/1820118"
---

![](http://dl.iteye.com/upload/attachment/0081/0550/bcf54166-c56e-3b5d-a259-725d6c8f4579.jpg)  
 

```
#include "stdio.h"
#include "string.h"

int main(){
	int i,n;
	char id[16],st[9],et[9];
	char id1[16],st1[9],et1[9],name1[16],name2[16];
	scanf("%d", &n);
	if(n != 0){
		scanf("%s%s%s",id,st,et);

		strcpy(name1, id);
		strcpy(name2, id);
		strcpy(st1, st);
		strcpy(et1, et);
	
		for(i=1;i<n;i++){
			scanf("%s%s%s", id, st, et);
			if(strcmp(st, st1)<0){
				strcpy(st1, st);
				strcpy(name1, id);
			}
			if(strcmp(et, et1)>0){
				strcpy(et1, et);
				strcpy(name2, id);
			}
		}
	
		printf("%s %s", name1, name2);
	}
	
	return 0;
}
```