书中AC代码

#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int main() {
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE
char week[7][5] = {
"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"
};
char str1[70], str2[70], str3[70], str4[70];
cin.getline(str1, 70);
cin.getline(str2, 70);
cin.getline(str3, 70);
cin.getline(str4, 70);
// gets(str1);
// gets(str2);
// gets(str3);
// gets(str4);
int len1 = strlen(str1);
int len2 = strlen(str2);
int len3 = strlen(str3);
int len4 = strlen(str4);
int i;
//寻找str1和str2中第一对相同位置的A~G的大写字母
for(i = 0; i < len1 && i < len2; i++) {
if(str1[i] == str2[i] && str1[i] >= 'A' && str1[i] <= 'G') {
printf("%s ", week[str1[i] - 'A']);
break;
}
}
for(i++; i < len1 && i < len2; i++) {
if(str1[i] == str2[i]) {
if(str1[i] >= '0' && str1[i] <= '9') {
printf("%02d:", str1[i] - '0');
break;
} else if(str1[i] >= 'A' && str1[i] <= 'N') {
printf("%02d:", str1[i] - 'A' + 10);
break;
}
}
}
for(i = 0; i < len3 && i <len4; i++) {
if(str3[i] == str4[i]) {
if((str3[i] >= 'A' && str3[i] <= 'Z') || (str3[i] >= 'a' && str3[i] <= 'z')) {
printf("%02d", i);
break;
}
}
}
return 0;
}

自己写的,有一个没有AC,找不到哪里出错

#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std; int main() {
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
//char DD; //日期
#endif // ONLINE_JUDGE
int DD = 0, HH = 0, MM = 0;//小时,分钟
char week[7][5] = {
"MON", "THU", "WED", "THU", "FRI", "SAT", "SUN"
};
char temp[4][70] = {0};
int len[4] = {0};
for(int i = 0; i < 4; i++) {
cin.getline(temp[i], 70);
len[i] = strlen(temp[i]);
//for(int j = 0; j < len[i]; j++) printf("")
}
// for(int i = 0; i < 4; i++) {
// printf("len: %d, string: %s\n", len[i], temp[i]);
//
// }
int smalllen = 0;
if(len[0] < len[1]) smalllen = len[0];
else smalllen = len[1];
int t = 0;
int i = 0;
for(i = 0; i < smalllen; i++) { //查找日期
if(temp[0][i] == temp[1][i]) {
if('A' <= temp[0][i] && 'G' >= temp[0][i]) {
// printf("temp[0][%d]:%c\n", i, temp[0][i]);
DD = temp[0][i] - 'A';
// printf("DD:%d\n", DD);
break;
}
}
}
for(i++; i < smalllen; i++) { //在上面的基础再往后搜索小时
if(temp[0][i] == temp[1][i]) {
if('0' <= temp[0][i] && '9' >= temp[0][i]) {
HH = temp[0][i] - '0';
// printf("temp[0][%d]:%c\n", i, temp[0][i]);
// printf("HH:%d\n", HH);
break;
} else if('A' <= temp[0][i] && 'N' >= temp[0][i]) {
HH = temp[0][i] - 'A' + 10;
// printf("temp[0][%d]:%c\n", i, temp[0][i]);
// printf("HH:%d\n", HH);
break;
}
}
}
smalllen = 0;
if(len[2] < len[3]) smalllen = len[2];
else smalllen = len[3];
for(int i = 0; i < smalllen; i++) {
if(temp[2][i] == temp[3][i]) {
if(('A' <= temp[2][i] && 'Z' >= temp[2][i]) || ('a' <= temp[2][i] && 'z' >= temp[2][i])) {
// printf("temp[2][%d]:%c\n", i, temp[0][i]);
MM = i;
// printf("MM:%d\n", MM);
break;
}
}
}
printf("%s %02d:%02d", week[DD], HH, MM);
return 0;
}

PAT B1014/A1061 福尔摩斯的约会(20)的更多相关文章

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

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

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

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

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

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

  4. PAT Basic 1014 福尔摩斯的约会 (20 分)

    大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm.大侦探很快就明白了,字条上奇 ...

  5. PAT Basic 1014 福尔摩斯的约会 (20 分) Advanced 1061 Dating (20 分)

    大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm.大侦探很快就明白了,字条上奇 ...

  6. PAT乙级:1014 福尔摩斯的约会 (20分)

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

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

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

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

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

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

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

随机推荐

  1. 2019icpc沈阳网络赛 D Fish eating fruit 树形dp

    题意 分别算一个树中所有简单路径长度模3为0,1,2的距离和乘2. 分析 记录两个数组, \(dp[i][k]\)为距i模3为k的子节点到i的距离和 \(f[i][k]\)为距i模3为k的子节点的个数 ...

  2. 快速掌握Python的捷径-Python基础前传(1)

    文: jacky(朱元禄) 开文序 最近看新闻,发现高考都考Python了,随着人工智能的火热,学数据科学的人越来越多了!但对于数据行业本身来说,现象级的火热,这并不是什么好事. 方丈高楼平地起,无论 ...

  3. nginx实现动静分离的负载均衡集群

    实战: 一.源码编译安装nginx [root@tiandong63 ~]#yum groupinstall "Development Tools" "Developme ...

  4. Mac 下python3 [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed 解决方法

    原文:http://blog.yuccn.net/archives/625.html python3.6下使用urllib 的request进行url 请求时候,如果请求的是https,请求可以会出现 ...

  5. Phos 技术服务支持

    Phos Mail: tencenter@163.com

  6. Ubuntu配置ISCSI

      target端: 1.安装 iscsi target相关的软件 $ sudo apt-get install iscsitarget iscsitarget-source iscsitarget- ...

  7. LC 957. Prison Cells After N Days

    There are 8 prison cells in a row, and each cell is either occupied or vacant. Each day, whether the ...

  8. query和exec区别

    1.PDO::query PDO::query执行一条SQL语句,如果通过,则返回一个PDOStatement对象.PDO::query函数有个“非常好处”,就是可以直接遍历这个返回的记录集. 示例如 ...

  9. WampServer 下载以及安装问题 以及配置远程连接MYSQL

    WampServer 3.0 下载: http://dl.pconline.com.cn/download/52877-1.html 碰到的问题DDL无法添加,解决方法:MSVCR110.DLL fo ...

  10. MySQL数据库同步工具的设计与实现

    一.背景 在测试过程中,对于不同的测试团队,出于不同的测试目的,我们可能会有多套测试环境.在产品版本迭代过程中,根据业务需求,会对数据库的结构进行一些修改,如:新增表.字段.索引,修改表.字段索引等操 ...