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. mysql host'XXX' is not allowed to connect to this mysql server

    错误的原因一般是没有添加 IP可远程的权限. 首先以 root 帐户登陆 MySQL 1.在 Windows 主机中点击开始菜单,运行,输入“cmd”,进入控制台,然后cd 进入MySQL 的 bin ...

  2. Redis-安装时问题整理

    一.Redis编译: 1.问题:make gcc error yum –y install gcc 2.问题:安装报错 error: jemalloc/jemalloc.h: No such file ...

  3. 模拟的confirm

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...

  4. Django商城项目笔记No.15用户部分-用户中心邮箱验证

    首先增加前端页面success_verify_email.html页面 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitiona ...

  5. PyQt5--EventSender

    # -*- coding:utf-8 -*- ''' Created on Sep 14, 2018 @author: SaShuangYiBing Comment: This example is ...

  6. Secure Shell相关设置

    1.清空known hosts记录 ctrl+shift+j调出js控制台后,输入: term_.command.removeAllKnownHosts()

  7. 多线程之CAS

    在JDK 5之前Java语言是靠synchronized关键字保证同步的,这会导致有锁 锁机制存在以下问题: (1)在多线程竞争下,加锁.释放锁会导致比较多的上下文切换和调度延时,引起性能问题. (2 ...

  8. CSS属性书写顺序及命名规则

    /* mozilla.org Base Styles * maintained by fantasai */ /* Suggested order: * display * list-style * ...

  9. 如何利用Grunt生成对应的Source Map文件,线上代码压缩使用chrome浏览器便于调式

    如何利用Grunt生成对应的Source Map文件,线上代码压缩使用chrome浏览器便于调式 首先我们来说说为何要生成sourceMap文件呢?简单的说,sourceMap是为了压缩后的代码调式提 ...

  10. 2.2《想成为黑客,不知道这些命令行可不行》(Learn Enough Command Line to Be Dangerous)——列表

    也许最常用的Unix命令是ls了,它是'list'的简写(Listing 8) Listing 8 用ls以列表的形式显示文件和目录(内容输出跟各自电脑有关) $ ls Desktop Downloa ...