PAT(甲级)1061
2015-09-26 11:00
393 查看
1061. Dating (20)
时间限制50 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". It took him only a minute to figure out that those strange strings are actually referring to the coded time "Thursday 14:04" -- since
the first common capital English letter (case sensitive) shared by the first two strings is the 4th capital letter 'D', representing the 4th day in a week; the second common character is the 5th capital letter 'E', representing the 14th hour (hence the hours
from 0 to 23 in a day are represented by the numbers from 0 to 9 and the capital letters from A to N, respectively); and the English letter shared by the last two strings is 's' at the 4th position, representing the 4th minute. Now given two pairs of strings,
you are supposed to help Sherlock decode the dating time.
Input Specification:
Each input file contains one test case. Each case gives 4 non-empty strings of no more than 60 characters without white space in 4 lines.
Output Specification:
For each test case, print the decoded time in one line, in the format "DAY HH:MM", where "DAY" is a 3-character abbreviation for the days in a week -- that is, "MON" for Monday, "TUE" for Tuesday, "WED" for Wednesday, "THU" for Thursday, "FRI" for Friday, "SAT"
for Saturday, and "SUN" for Sunday. It is guaranteed that the result is unique for each case.
Sample Input:
3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm
Sample Output:
THU 14:04
#include <iostream> #include <iomanip> using namespace std; ////////////////////////////////// // buggggggggggggg!!! int main() { string str1,str2,str3,str4; cin >>str1 >>str2 >>str3 >>str4; const char *p1 = &str1[0]; const char *p2 = &str2[0]; int day,hour,min; bool found=false; day =-1; while(*p1 != '\0' && *p2 != '\0'){ if(*p1 == *p2 && *p1 <='G' && *p1 >='A' && !found){ day = *p1-'A'+1; } if(*p1 == *p2 && found){ if(*p1 >='0' && *p1 <='9'){ hour = *p1 -'0'; break; } else if(*p1 >='A' && *p1 <='N'){ hour = *p1- 'A' + 10; break; } } if(day != -1) found = true; p1++; p2++; } p1 = &str3[0]; p2 = &str4[0]; min = 0; while(*p1 != '\0' && *p2 !='\0'){ if(*p1 == *p2 && (*p1 <='z' && *p1 >='a' || *p1 >='A' && *p1 <='Z')) break; min++; p1++; p2++; } switch(day){ case 1:{ cout <<"MON " ; break; } case 2:{ cout <<"TUE "; break; } case 3:{ cout <<"WED "; break; } case 4:{ cout <<"THU "; break; } case 5:{ cout <<"FRI "; break; } case 6:{ cout <<"SAT "; break; } case 7:{ cout <<"SUN "; break; } } cout <<hour <<':' <<setw(2) <<setfill('0') <<min <<endl;//bugggggggggggggggggggggggg! }
相关文章推荐
- Python常用模块
- Java理论学时第一节。课后作业。
- PAT(甲级)1060
- Codevs P1669 运输装备
- 图解Linux命令之--chattr命令
- Win7系统使用IE9浏览器看视频没图像怎么办?使用IE9浏览器看视频没图像的解决方法
- 软件测试与验证 prime_path 基路径算法暴力版
- 关于Xutils框架出现无法访问HttpRequestBase 找不到org.apache.http.client.methods.HttpRequestBase解决方案
- PAT(甲级)1059
- ArcGIS教程:坡度
- ViewPager防止Fragment销毁以及取消Fragment的预加载
- 原生js多动画同时运动框架(style属性多项同时改变)
- 观察UDP buffer size 情况
- PAT(甲级)1058
- 条款42:了解typename的双重意义
- JMS学习
- 283:Move Zeroes
- 大话设计模式笔记 观察者模式
- (算法)和为0的最大连续子数组
- 树的深度优先与广度优先遍历