UVa12136 - Schedule of a Married Man(排序)
来源:互联网 发布:c编程教学免费视频 编辑:程序博客网 时间:2024/05/29 15:40
Last year we set a problem on bachelor arithmetic whichmade some bachelors really unhappy. So to even things up, we are making aproblem on the tough schedule of a married man.
Our dashing hero Danny has recently got married and thathas created a lot of problems for him, at least that is what his friends think.So many broken promises, so many missed appointments and dinners. Err! Danny,now is losing tracks of even simplest of calculations, so you must help him todecide whether he can attend his meeting or not. Danny is busy with his wifefor a large portion of the day. This large portion is denoted by a startingtime and an ending time. Then Danny has an important meeting in a day, hemisses that if it overlaps or touches (For example, if Danny�s time span withhis wife finishes at 18:00 and the meeting starts at 18:00 then the twoschedules conflict and Danny misses the meeting) the time scheduled for hiswife. Given the time span Danny has allotted for his wife and the time span ofthe meeting you, will have to find whether Danny misses that meeting or not.
Input
First line of the input file contains an integer N(0<N<2001) which denotes how many sets of inputs are there. The input foreach set is given in two lines. The description for each set is given below:
First line of each set contains two strings separated by asingle space. These two strings denote the time span Danny is busy with hiswife. The second line also contains two strings which denotes the time whenDanny has to attend a meeting. All the strings that denote time are of theformat hh:mm (two digit for hour and two digit for minute). For example �fortyfive past eight� (Morning) is denoted as 08:45, �forty five past 9� (night) isdenoted as 21:45.� You can assume thatall times are valid 24-hour clock time, starting time strictly precedes endingtime and all times are within a single day.
Output
For each set of input produce one line of output. Thisline contains the serial of output followed by a string which denotes Danny�sdecision. If Danny can attend the meeting then print �Hits Meeting� and ifDanny misses (Mrs) the meeting as it conflicts with the time allotted for hiswife print �Mrs Meeting� instead.
Sample Input��������������������������� Output for SampleInput
3
17:47 22:40
06:18 17:04
10:44 17:05
01:11 01:27
03:36 19:02
14:33 15:24
Case 1: Hits Meeting
Case 2: Hits Meeting
Case 3: Mrs Meeting
题意:给出两个时间段,判断时间是否有冲突
思路:根据起始时间将两个赶时间段排序
#include <cstdio>#include <algorithm>using namespace std;const int MAXLINE = 100;struct Time{int start, end;bool operator < (const Time &other) const{if (start != other.start) return start < other.start;return end < other.end;}};char buf[MAXLINE];Time time[2];bool input(){ gets(buf);int hour1, min1, hour2, min2;sscanf(buf, "%d:%d %d:%d", &hour1, &min1, &hour2, &min2);time[0].start = hour1 * 60 + min1;time[0].end = hour2 * 60 + min2;gets(buf);sscanf(buf, "%d:%d %d:%d", &hour1, &min1, &hour2, &min2);time[1].start = hour1 * 60 + min1;time[1].end = hour2 * 60 + min2;sort(time, time + 2); return true;}void solve(){ if (time[0].end < time[1].start) {printf("Hits Meeting\n");} else {printf("Mrs Meeting\n");}}int main() {#ifndef ONLINE_JUDGE freopen("d:\\OJ\\uva_in.txt", "r", stdin);#endif int cas;gets(buf);sscanf(buf, "%d", &cas); for (int i = 1; i <= cas; i++) { input(); printf("Case %d: ", i); solve(); } return 0;}
- UVa12136 - Schedule of a Married Man(排序)
- nike air max 1 who had married a. Sources said that in the second half of last year
- hogan olympia donna After you get married have a family
- Fix a Man-made Mistake in Java Project of Eclipse
- codeforces 732B - Cormen --- The Best Friend Of a Man
- B. Cormen — The Best Friend Of a Man
- Cormen — The Best Friend Of a Man (贪心)
- The woman was made of a rib out of the side of man...
- The Call of the Wild——6、For the love of a man
- A Story of Superior man--The 14th MiniStory of AJ
- Schedule of funds
- SCHEDULE OF THIS WEEK
- Man page of lpfc
- Man page of HAGRP
- man page of jikes
- man of grep
- Liferay Schedule a job
- A. Alena's Schedule
- Android 混淆JS交互没反应
- centos7 安装 mariadb 及安装设置
- 输出杨辉三角前10行
- @[],@()的使用
- 工大培训——day3 G题
- UVa12136 - Schedule of a Married Man(排序)
- 第十三周项目5 输出数字出现的次数
- 大话TCP/IP协议之HTTP网络协议(一)
- Linux程序设计读书笔记------入门
- 枚举类型的用法
- 预编译
- 网站重构——轻量化的网站架构设计一,使用nodejs sqlite3查询数据
- 第十三周 项目五--字符串操作(2.2)字符串复制功能---两个数组中的字符复制在一个数组中
- PLS 画图结果<五>