书中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. java中的变量和数据类型

    变量和javascript的变量含义一样 在Java中,变量分为两种:基本类型的变量和引用类型的变量.(javascript中同样是这样的) 基本数据类型 基本数据类型是CPU可以直接进行运算的类型. ...

  2. HDU 5705 Clock(2016杭电女生专场1004)——角度追及问题

    题意是给出一个当前的时间和角度a,问从现在开始的下一个时针和分针形成角度a的时间是多少,时间向下取整. 分析:时针3600s走30°,故120s走1°,分针3600s走360°,故10s走1°,那么每 ...

  3. Android RecyclerView实现加载多种条目类型

    今天咱们是用RecyclerView来实现这个多种Item的加载. 其实最关键的是要复写RecyclerView的Adapter中的getItemViewType()方法 这个方法就根据条件返回条目的 ...

  4. Css设置字体

    另,考虑到文件编码问题,在css中推荐使用中文字体的英文表示法,以下附常见中文字体的英文名:Mac OS的一些:Georgia  数字高低起伏Comic Sans MS 好看的英文字体华文细黑:STH ...

  5. MySQL 如何使用show processlist进行过滤

    在使用show processlist的时候,直接使用会显示很多的内容,无法很快找到需要的信息. 如何过滤操作呢? 其实,show processlist展示的内容是从information_sche ...

  6. backbone之collection

    最近要用到backbone.js,网上也找了些资料,但是就看到一个开头还可以,往下看基本就看不下去了,幸好有这本书[LeanpubRead] Backbone.Marionette.js A Gent ...

  7. java代码实现简体繁体转换

    汉字分为简体和繁体字,这是众所周知的,虽然繁体字中国大陆这边用的并不会太多,但时不时的还是会使用到.那么,如何做到简体字和繁体字的转换呢?其实很简单,这里附上一个java版本的简繁体转换,用网上找的接 ...

  8. 小D课堂-SpringBoot 2.x微信支付在线教育网站项目实战_2-3.热部署在Eclipse和IDE里面的使用

    笔记 3.热部署在Eclipse和IDE里面的使用     简介:讲解热部署的好处及使用注意事项,在eclipse里面默认开启,在IDE里面默认关闭                  1.增加依赖 & ...

  9. vue 组件属性props,特性驼峰命名,连接线使用

    网址:https://www.cnblogs.com/alasq/p/6363160.html 总结如下:vue的组件的props属性支持驼峰命名,不支持连接线命名,使用是用连接线进行赋值或者数据绑定 ...

  10. golang 中国代理

    vim /etc/profile export GO11MODULE=onexport GO111MODULE=onexport GOPROXY=https://goproxy.io source / ...