书中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. HSBToolBox

    HSBToolBox.exe Unzip all files to the folder where Hearthbuddy.exeThen just run HSBToolBox.exe [asse ...

  2. nginx状态码

    200:服务器成功返回网页 403:服务器拒绝请求.404:请求的网页不存在 499:客户端主动断开了连接.500:服务器遇到错误,无法完成请求.502:服务器作为网关或代理,从上游服务器收到无效响应 ...

  3. Kbengine游戏引擎-【4】demo-kbengine_unity3d_demo 在容器docker上安装测试

    git地址:https://github.com/kbengine/kbengine_unity3d_demo Demo中文地址:https://github.com/kbengine/kbengin ...

  4. python安装gmpy2模块时出现错误的解决

    接下来表演的是安装Python模块gmpy2 此模块用来进行高精度计算的模块,个人根据需求常用来进行rsa加密算法的计算 作为一个资质浅淡的ubuntu玩家,这些知识当然是在网上搜索得到的,不过网上的 ...

  5. MOCK服务小结

    前言: 说到mock,大家会想到单测中的mock,测试同学会想到httpmock服务等. mock的作用:程序运行过程中,设定过滤规则及返回值,来满足固定的数据解析,解决不容易构造或者获取的数据对象. ...

  6. 找不到FileProvider类怎么办?找不到R资源怎么办?APPT2错误怎么办?

    坑2: 在使用上述解决方案时,需要加入android.support.v4.content.FileProvider这个类,当时我没有这个包.但是在引入相应的依赖包后,各种异常就出现了. 先是把And ...

  7. Qt编写自定义控件15-百分比仪表盘

    前言 百分比仪表盘,主要的应用场景是展示销售完成率.产品合格率等,也可以作为一个进度百分比展示,可以独立设置对应的标题文字,标题文字的颜色和整体的颜色都可以单独设置,建议设置成统一的风格,这样会显得更 ...

  8. Python 线程----线程方法,线程事件,线程队列,线程池,GIL锁,协程,Greenlet

    主要内容: 线程的一些其他方法 线程事件 线程队列 线程池 GIL锁 协程 Greenlet Gevent 一. 线程(threading)的一些其他方法 from threading import ...

  9. v-on可以监听多个方法吗?

    原文地址 v-on可以监听多个方法 <template> <div class="about"> <button @click="mycli ...

  10. Postman配置环境变量添加token

    postman测试接口时,每次都需要获取token以后,复制到接口里,特别复杂. 这里通过把获取token接口的返回数据添加到环境变量,然后将环境变量名设置在其他接口的token中,获取一次token ...