14/20

#include<bits/stdc++.h>
using namespace std;
map<char,string> day;
int main(){
day['A']="MON";
day['B']="TUE";
day['C']="WED";
day['D']="THU";
day['E']="FRI";
day['F']="SAT";
day['G']="SUN"; string a,b,c,d;
char date;
char hour;
bool flag[2]={false};
cin>>a>>b>>c>>d;
int index=0,len=min(a.length(),b.length());
for(int i=0;i<len;i++){
if(flag[0]&&flag[1])break;//both found.
//find 0~9 A~N
if(flag[0]&&a[i]==b[i]&&((a[i]>=0&&a[i]<=9)||(a[i]>='A'&&a[i]<='N'))&&!flag[1]){hour=a[i];flag[1]=true;}
//find A~G
if(a[i]==b[i]&&a[i]>='A'&&a[i]<='G'&&!flag[0]){date=a[i];flag[0]=true;}
}
cout<<day[date]<<' ';
if(hour>=0&&hour<=9)cout<<hour<<':';
else cout<<10+hour-'A'<<':'; int len2=min(c.length(),d.length());
int index2=0;
for(int i=0;i<len2;i++){
if(c[i]==d[i]&&((c[i]>='a'&&c[i]<='z')||(c[i]<='Z'&&c[i]>='A'))){index2=i;break;}
}
printf("%02d\n",index2);
return 0;
}

排查bug真是心酸。原来没有格式化,我下面的分钟都格式化了,却没有给小时格式化,太傻了。

20/20

#include<bits/stdc++.h>
using namespace std;
map<char,string> day;
int main(){
day['A']="MON";
day['B']="TUE";
day['C']="WED";
day['D']="THU";
day['E']="FRI";
day['F']="SAT";
day['G']="SUN"; string a,b,c,d;
char date;
char hour;
bool flag[2]={false};
cin>>a>>b>>c>>d;
int len=min(a.length(),b.length());
for(int i=0;i<len;i++){
if(flag[0]&&flag[1])break;//both found.
//find 0~9 A~N
if(flag[0]&&a[i]==b[i]&&((a[i]>='0'&&a[i]<='9')||(a[i]>='A'&&a[i]<='N'))&&!flag[1]){hour=a[i];flag[1]=true;}
//find A~G
if(a[i]==b[i]&&a[i]>='A'&&a[i]<='G'&&!flag[0]){date=a[i];flag[0]=true;}
}
cout<<day[date]<<' ';
if(hour>='0'&&hour<='9')printf("%02d:",hour-'0');
else printf("%02d:",hour-'A'+10); int len2=min(c.length(),d.length());
int index2=0;
for(int i=0;i<len2;i++){
if(c[i]==d[i]&&((c[i]>='a'&&c[i]<='z')||(c[i]<='Z'&&c[i]>='A'))){index2=i;break;}
}
printf("%02d\n",index2);
return 0;
}

B1014. 福尔摩斯的约会的更多相关文章

  1. 【算法笔记】B1014 福尔摩斯的约会

    1014 福尔摩斯的约会 (20 分) 大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hy ...

  2. 【PAT】B1014 福尔摩斯的约会

    因为前面两字符串中第 1 对相同的大写英文字母(大小写有区分)是第 4 个字母D,代表星期四: 第 2 对相同的字符是 E ,那是第 5 个英文字母,代表一天里的第 14 个钟头(于是一天的 0 点到 ...

  3. PAT乙级 1014. 福尔摩斯的约会 (20)

    1014. 福尔摩斯的约会 (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 大侦探福尔摩斯接到一张奇怪的 ...

  4. PAT-乙级-1014. 福尔摩斯的约会 (20)

    1014. 福尔摩斯的约会 (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 大侦探福尔摩斯接到一张奇怪的 ...

  5. 浙江大学PAT上机题解析之1014. 福尔摩斯的约会 (20)

    1014. 福尔摩斯的约会 (20) 时间限制   50 ms 内存限制   32000 kB 代码长度限制   8000 B 判题程序     Standard     作者     CHEN, Y ...

  6. PAT 乙级 1014 福尔摩斯的约会 (20) C++版

    1014. 福尔摩斯的约会 (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 大侦探福尔摩斯接到一张奇怪的 ...

  7. PAT 1014 福尔摩斯的约会 (20)(代码+思路)

    1014 福尔摩斯的约会 (20)(20 分) 大侦探福尔摩斯接到一张奇怪的字条:"我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfd ...

  8. 【PAT】1014. 福尔摩斯的约会 (20)

    1014. 福尔摩斯的约会 (20) 大侦探福尔摩斯接到一张奇怪的字条:“我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hy ...

  9. PAT (Basic Level) Practise (中文)- 1014. 福尔摩斯的约会 (20)

    http://www.patest.cn/contests/pat-b-practise/1014 1014. 福尔摩斯的约会 (20) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 ...

随机推荐

  1. 【Amazon 必考】Amazon Leadership Principles 亚马逊领导力准则

    Leadership Principles,也就是领导力准则,不仅仅是几条用来鼓舞人心的口号,更是成就了Amazon特有公司文化的秘诀.不管是为新项目讨论创意.寻找解决客户问题的方案,还是面试求职者时 ...

  2. JAVA 连接 SQL Server 2008:java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

    新项目需要修改Java开发的MES系统...Java忘的也差不多了...简单尝试以下JAVA连接SQL Server吧,没想到坑还是很多的.以前直接连oracle时没有这么多麻烦啊....可能微软和o ...

  3. October 18th 2017 Week 42nd Wednesday

    Only someone who is well-prepared has the opportunity to improvise. 只有准备充分的人才能够尽兴表演. From the first ...

  4. redis 配置文件示例

    # redis 配置文件示例 # 当你需要为某个配置项指定内存大小的时候,必须要带上单位,# 通常的格式就是 1k 5gb 4m 等酱紫:## 1k  => 1000 bytes# 1kb =& ...

  5. Spring Boot 集成 thymeleaf 模版引擎

    Spring Boot 建议使用 HTML 来完成动态页面.Spring Boot 提供了大量的模版引擎,包括 Thymeleaf.FreeMarker.Velocity等. Spring Boot ...

  6. 记一次MyBatis的错误

    错误信息:java.lang.StackOverflowError 关于这个错误的深度解析,大家可以参考这篇博文,比较详细:https://blog.csdn.net/zc375039901/arti ...

  7. java.lang.NoSuchMethodError: No static method getFont

    最近在Android Studio升级3.0后,在AlertDialog弹窗时报出了如下问题: java.lang.NoSuchMethodError: No static method getFon ...

  8. pyspider爬取数据存入mysql--2.测试数据库能否连通

    做一个简单的测试,看数据能否存入mysql 1 #!/usr/bin/env python 2 # -*- encoding: utf-8 -*- 3 # Created on 2017-10-26 ...

  9. JS模拟滚动条(有demo和源码下载,支持拖动 滚轮 点击事件)

    由于游览器自带的滚动条在美观方面并不是很好看,所以很多设计师希望通过自己设计出来的滚动条来做这样的效果,JS模拟滚动条其实很早看到jQuery有这样的插件或者KISSY有这样的组件,一直想着自己什么时 ...

  10. 有关C++的数据类型(int,long,short,float,double等等)

    再看C++ prime plus 第六版的时候 对数据类型又一次有些乱了,在看了这篇博客后,重新清晰起来了. 有关C++的数据类型(int,long,short,float,double等等)