PAT1061:Dating
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&Hyscvnm
Sample Output:
THU 14:04 思路
字符串处理问题,根据题目要求处理好就行,比较考验细心和耐心。
注意第一个字母的范围在A到G7个字母内(代表一周七天),第二个相同的字符是0到9以及A到N(10点到23点)。第三个字符是另外两个字符串共有的相同位置的英文字符。
最后的输出要转换成时间形式,因此要注意0到9的数字需要用00到09这样的形式表示。 代码
#include<iostream>
#include<vector>
#include<math.h>
using namespace std; vector<string> week = {"MON","TUE","WED","THU","FRI","SAT","SUN"}; int main()
{
string s1,s2,s3,s4;
while(cin >> s1 >> s2 >> s3 >> s4)
{
int len1 = min(s1.size(),s2.size()),len2 = min(s3.size(),s4.size());
vector<int> key();
int i = ;
for(;i < len1; i++)
{
if(s1[i] == s2[i] && (s1[i] >= 'A' && s1[i] <='G'))
{
key[] = s1[i] - 'A';
break;
}
} for(int j = i + ;j < len1;j++)
{
if(s1[j] == s2[j])
{
if(s1[j] <= '' && s1[j] >= '')
{
key[] = s1[j] - '';
break;
}
else if(s1[j] >= 'A' && s1[j] <= 'N')
{
key[] = s1[j] - 'A' + ;
break;
}
}
} for(int j = ; j < len2;j++)
{
if(s3[j] == s4[j] &&((s3[j] >= 'a' && s3[j] <= 'z') || (s3[j] >= 'A' && s3[j] <= 'Z')))
{
key[] = j;
break;
}
} cout << week[key[]] << " " ;
if(key[] < )
cout << "" << key[] <<":";
else
cout << key[] << ":";
if(key[] < )
cout <<"" << key[] << endl;
else
cout << key[] << endl;
}
}
PAT1061:Dating的更多相关文章
- pat1061. Dating (20)
1061. Dating (20) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Sherlock Holmes ...
- hdu 2579 Dating with girls(2)
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2579 Dating with girls(2) Description If you have sol ...
- hdu 2578 Dating with girls(1)
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2578 Dating with girls(1) Description Everyone in the ...
- 10 signs you’re dating the wrong person
10 signs you’re dating the wrong person10个迹象表明TA不是你的真心人 Do you have any exes who were so awful ...
- hdoj 2579 Dating with girls(2)【三重数组标记去重】
Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- Dating with girls(1)(二分+map+set)
Dating with girls(1) Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- Shine we together: A innovative dating site using 2012 Nobel Laureate Roth's algorithm
Abstract Our dating site introduced scoring and its related functionalities innovatively, conforming ...
- Codeforces 852I Dating 树上莫队
Dating 随便树上莫队搞一搞就好啦. #include<bits/stdc++.h> #define LL long long #define LD long double #defi ...
- A1061. Dating
Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akD ...
随机推荐
- 打造你的开发神器——介绍Android Studio上的几个插件
这个月因为各种事情在忙,包括赶项目,回老家,还有准备旅游的事,所以应该写不了四篇博客了.今天介绍一下关于Android Studio 的几个好用的插件,都是我在用的,它们或能帮你节省时间,或者让你心情 ...
- win32 线程通信初步
// 线程通信机制.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #define NUM_THREADS 10 #include < ...
- 苹果新的编程语言 Swift 语言进阶(十一)--实例的初始化与类的析构
一 .实例的初始化 实例的初始化是准备一个类.结构或枚举的实例以便使用的过程.初始化包括设置一个实例的每一个存储属性为一个初始值,以及执行任何其它新的实例能够使用之前需要的设置或初始 ...
- Java学习网站大全
Java学习网站 http://www-900.ibm.com/developerWorks/cn/java/index.shtml IBM的JAVA专题--永远的蓝色巨人 http://www.hu ...
- 安装docker及配置Android开发环境
安装docker 官方原来的安装docker的脚本https://get.docker.com/已经过时,现在使用的是https://get.docker.com/,命令如下: curl -s htt ...
- unity C#更改系统默认鼠标指针
最近项目需要替换鼠标的默认图标,实现的效果是初始状态为一种图标,点击鼠标左键要换成另一种图标,按网上通用的方法做了以后,隐藏鼠标指针,在指针的位置画一个图片就可以了,但不知道怎么回事,这种方法画的图标 ...
- objective-c中关于类型编码的解释
在某些情况下,我们需要动态的向一个类插入一个实例方法(也可以是一个类方法):这时我们可以用class_addMethod函数来完成: BOOL class_addMethod ( Class cls, ...
- Hadoop Bloom Filter 使用
1.Bloom Filter 默认的 BloomFilter filter =new BloomFilter(10,2,1); // 过滤器长度为10 ,用2哈希函数,MURMUR_HASH (1) ...
- Numpy快速入门——shape属性,你秒懂了吗
前言 对于学习NumPy(Numeric Python),首先得明确一点是:Numpy 是用来处理矩阵数组的. shape 属性 对于shape函数,官方文档是这么说明: the dimensions ...
- 春天JDBC事务管理
JDBC事务管理 春天提供编程式的事务管理(编程式事务管理)与声明式的事务管理(声明式事务management),为不同的事务实现提供了一致的编程模型,这节以JDBC事务为例,介绍Spring的事务管 ...