PAT(甲级)1061
来源:互联网 发布:葫芦娃 知乎 编辑:程序博客网 时间:2024/05/29 13:23
1061. Dating (20)
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&HyscvnmSample 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!}
- PAT(甲级)1061
- 浙大PAT甲级 1061
- PAT甲级1061
- 浙大PAT甲级-1061
- PAT 甲级
- PAT甲级 A1025.PAT RANKING
- PAT 甲级 1025 PAT Ranking
- PAT(甲级)1003
- PAT(甲级)1004
- PAT(甲级)1005
- PAT(甲级)1006
- PAT(甲级)1007
- PAT(甲级)1008
- PAT(甲级)1009
- PAT(甲级)1010
- PAT(甲级)1011
- PAT(甲级)1012
- PAT(甲级)1013
- Codevs P1669 运输装备
- 【数据结构与算法】Hash表
- PAT(甲级)1060
- 教你下载百度网盘已失效资源链接
- VS2012如何让两个或者多个项目共享同一个文件
- PAT(甲级)1061
- Python常用模块
- Android进阶之OptionsMenu+ContextMenu+subMenu
- linux多线程环境下的抢尸行为(system返回-1:No child processes)http://www.aiuxian.com/article/p-129935.html
- Android网络编程之JAVA IO流简单了解
- 关于ASP.NET MVC4中,下载APK文件错误
- 《深入理解java虚拟机》之内存管理
- Android开发笔记——对话框和通知
- mysql 创建一个用户,指定一个数据库