Pat(Advanced Level)Practice--1061(Dating)
来源:互联网 发布:小米平板2 ubuntu 编辑:程序博客网 时间:2024/06/01 08:15
Pat1061代码
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<cstdio>#include<cstring>#define MAX 65using namespace std;int main(int argc,char *argv[]){int i,j;char day,hour,minute;char s1[MAX],s2[MAX],s3[MAX],s4[MAX];scanf("%s%s%s%s",s1,s2,s3,s4);for(i=0;s1[i]!='\0'&&s2[i]!='\0';i++){if(s1[i]==s2[i]&&s1[i]>='A'&&s1[i]<='G'){day=s1[i];break;}}i++;for(;s1[i]!='\0'&&s2[i]!='\0';i++){if(s1[i]==s2[i]&&((s1[i]>='A'&&s1[i]<='N')||(s1[i]>='0'&&s1[i]<='9'))){hour=s1[i];break;}}for(j=0;s3[j]!='\0'&&s4[j]!='\0';j++){if(s3[j]==s4[j]&&((s3[j]>='a'&&s3[j]<='z')||(s3[j]>='A'&&s3[j]<='Z'))){minute=j;break;}}switch(day){case 'A':printf("MON");break;case 'B': printf("TUE");break;case 'C':printf("WED");break;case 'D':printf("THU");break;case 'E':printf("FRI");break;case 'F':printf("SAT");break;case 'G':printf("SUN");break;}if(hour>='0'&&hour<='9')printf(" %02d",hour-'0');elseprintf(" %d",hour-'A'+10);printf(":%02d\n",minute);return 0;}注意一下,day,hour,minute的取值范围就可以了;
- Pat(Advanced Level)Practice--1061(Dating)
- PAT (Advanced Level) Practise 1061 Dating (20)
- PAT (Advanced Level) Practise 1061 Dating (20)
- PAT (Advanced Level) Practice 1006
- 【C++】PAT(advanced level)1061. Dating (20)
- 【PAT】【Advanced Level】1061. Dating (20)
- Pat(Advanced Level)Practice--1025(PAT Ranking)
- Pat(Advanced Level)Practice--1075(PAT Judge)
- Pat(Advanced Level)Practice--1003(Emergency)
- Pat(Advanced Level)Practice--1004(Counting Leaves)
- Pat(Advanced Level)Practice--1008(Elevator)
- Pat(Advanced Level)Practice--1010(Radix)
- Pat(Advanced Level)Practice--1015(Reversible Primes)
- Pat(Advanced Level)Practice--1024(Palindromic Number)
- Pat(Advanced Level)Practice--1028(List Sorting)
- Pat(Advanced Level)Practice--1029(Median)
- Pat(Advanced Level)Practice--1030(Travel Plan)
- Pat(Advanced Level)Practice--1035(Password)
- POJ3253 Fence Repair 小顶堆+贪心
- Utilities and SDK for Subsystem for UNIX-based Applications in Windows 8 and Windows Server 2012
- 数据结构 栈(四则表达式)
- 【c++系列14】让数据类型成为对象
- Maven镜像地址收集
- Pat(Advanced Level)Practice--1061(Dating)
- ubuntu 163 mirrors
- OCP-1Z0-051 第80题 DATE数据类型
- Config程序配置文件操作实践进阶之ConfigurationSectionGroup
- Html文档解析器 HtmlCleaner 编辑
- 学习笔记之三 获取系统时间的方法汇总
- 当在struts2中出现了404
- poj2021 字符串处理 BFS
- 数组