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, MONfor 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~G,0~9,A~N,不分大小写。

给出四个字符串,前两个字符串确定日期和小时, 后两个字符串确定分钟; 
     日期:前两个字符串第一个相等的大写字母(位置相同,字母相同)A~G 分别表示星期一到星期天
     小时:在找到日期的字符串后面继续查找,找到第一个相同的数字或字母(0~9,A~N)(位置也要相同),分别表示0~23
     分钟:在后面两个字符串中查找,第一个相等的字母,不分大小写, 字母相等的位置就是分钟

题解:

这里用cctype中的isalpha(),isdigit()判断字符是否为字母,或者数字。也可以用不等式来判断

AC代码:

#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
char a[],b[];
string week[]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
int main(){
cin>>a>>b;
string wk;
int hh,mm;
int f=;
int la=strlen(a),lb=strlen(b);
for(int i=;i<min(la,lb);i++){
if(f&&((a[i]>='A' && a[i]<='N')||(a[i]>='' && a[i]<=''))&&a[i]==b[i]){
if(a[i]>='A' && a[i]<='N') {
hh=a[i]-'A'+;
break;
}
else {
hh=a[i]-'';
break;
}
}
if(!f&&a[i]>='A' && a[i]<='G' &&a[i]==b[i]){
f=;
wk=week[a[i]-'A'];
}
} memset(a,'\0',sizeof(a));
memset(b,'\0',sizeof(b));
cin>>a>>b;
la=strlen(a);
lb=strlen(b);
for(int i=;i<min(la,lb);i++){
if(isalpha(a[i])&& a[i]==b[i]) {
mm=i;
break;
}
}
printf("%s %02d:%02d",wk.c_str(),hh,mm);
return ;
}

最新文章

  1. iOS之百度导航SDK的坐标转换
  2. 【Go入门教程1】Go 安装,GOROOT,GOPATH,Go工作空间
  3. 使用css3进行增强
  4. JavaScript-setInterval-周期性行定时器-倒计时
  5. [C#] 可空类型的实现原理
  6. Angular学习(5)- 数组双向梆定+filter
  7. hdoj 5194 DZY Loves Balls【规律&amp;&amp;gcd】
  8. 如何编写makefile
  9. 马的遍历 洛谷 p1443
  10. 每秒生成一千万个【可视有序】分布式ID的简单方案
  11. LeetCode--025--k个一组翻转链表(java)
  12. 09-伪数组 arguments
  13. python中的进程和线程
  14. ADO.Net 数据库查询
  15. spring security的简单应用
  16. C#编程(四十五)----------格式字符串
  17. C++ template —— 模板中的名称(三)
  18. centos6.2/6.3/6.4+nginx+mysql5.5+php5.3.14
  19. 【bzoj1096】仓库建设 斜率优化dp
  20. 百度搜索URL中的参数都是什么

热门文章

  1. 必须知道的String知识点
  2. CQOI2005 三角形面积并 和 POJ1177 Picture
  3. PL/SQL存储过程
  4. Codeforces Round #597 (Div. 2) D. Shichikuji and Power Grid
  5. 查看DOM对象的style样式,attributes属性,children
  6. GridView用数据源控件和用DataTable作为数据源的不同
  7. TensorFlow(十三):模型的保存与载入
  8. linux系列(十):cat命令
  9. express+mongoDB(mLab)做一个todolist小项目
  10. (7)打造简单OS-加载内核