【PAT】【Advanced Level】1061. Dating (20)
来源:互联网 发布:淘宝宝贝照片拍摄 编辑:程序博客网 时间:2024/06/02 04:39
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
https://www.patest.cn/contests/pat-a-practise/1061
https://www.nowcoder.com/pat/5/problem/4028
思路:
扫描,判断
CODE:
#include<iostream>#include<cstdio>#include<cstring>#include<string>//坑点:格式!using namespace std;string day[7]={"MON","TUE","WED","THU","FRI","SAT","SUN"};int main(){ int re1,re2,re3; string a,b,c,d; cin>>a>>b>>c>>d; int num=0; for (int i=0;i<min(a.length(),b.length());i++) { if (a[i]==b[i]) { //cout<<i<<" "<<a[i]<<endl; if (num==0) { if(a[i]>='A' && a[i]<='G') { num++; re1=a[i]-'A'; continue; } } if(num==1) if((a[i]>='A' && a[i]<='N')||(a[i]>='0' && a[i]<='9')) { //cout<<i<<" "<<a[i]<<endl; if (a[i]>='0' && a[i]<='9') { //cout<<"1"<<endl; re2=a[i]-'0'; break; } else if (a[i]>='A' && a[i]<='N') { //cout<<"2"<<endl; re2=10+(a[i]-'A'); break; } } } } for (int i=0;i<min(c.length(),d.length());i++) { if(c[i]==d[i]) { if ( (c[i]>='a' && c[i]<='z') ||(c[i]>='A'&&c[i]<='Z')) { re3=i; break; } } } cout<<day[re1]<<" "; if (re2<10) cout<<"0"; cout<<re2<<":"; if (re3<10) cout<<"0"; cout<<re3;}
- 【C++】PAT(advanced level)1061. Dating (20)
- 【PAT】【Advanced Level】1061. Dating (20)
- PAT (Advanced Level) 1061. Dating (20) 字符匹配
- PAT (Advanced Level) Practise 1061 Dating (20)
- PAT (Advanced Level) Practise 1061 Dating (20)
- PAT (Advanced) 1061. Dating (20)
- 1061. Dating (20)【字符串操作】——PAT (Advanced Level) Practise
- Pat(Advanced Level)Practice--1061(Dating)
- 1061. Dating (20)-PAT
- 【PAT】1061. Dating (20)
- PAT 1061. Dating (20)
- pat 1061. Dating (20)
- pat 1061. Dating (20)
- PAT 1061. Dating (20)
- PAT 1061. Dating (20)
- PAT A 1061. Dating (20)
- 【PAT甲级】1061. Dating (20)
- 1061. Dating (20)PAT甲级
- JavaScript判断移动端及pc端访问不同的网站
- mybatis的xml文件中列名和mysql数据库中的关键字冲突
- ZOJ 3447 Doraemon's Number Game(优先队列+高精度运算)
- 如何读写文本文件
- Cortex M3存储器映射
- 【PAT】【Advanced Level】1061. Dating (20)
- 链式队列
- 简单使用ActiveMQ
- C/C++ 内存布局详解(经典
- hdu 1729 Stone Game
- The Festive Evening (Codeforces
- 集合
- ST_VL53L0X开发记录_IIC读一个字节的函数的个人理解
- 文件锁以及多路复用方式解决多个用户对一个文件的操作