书中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. 使用已有的jmeter测试结果日志文件生成html报告

    当并发数较大的时候,经常会出现测试结束后没有生成html报告的情况 解决办法: 测试结束后,使用生成的jmeter测试结果日志文件.jtl生成html报告 基本命令格式: jmeter -g < ...

  2. python sqlite3学习笔记

    1.sqlite3.connect()参数说明 self.connect = sqlite3.connect(db_name,timeout=3,isolation_level=None,check_ ...

  3. FatMouse's Speed

    J - FatMouse's Speed DP的题写得多了慢慢也有了思路,虽然也还只是很简单的DP. 因为需要输出所有选择的老鼠,所以刚开始的时候想利用状态压缩来储存所选择的老鼠,后面才发现n太大1& ...

  4. 事件处理机制与Handler消息传递机制

    一.基于监听的事件处理机制 基于监听的时间处理机制模型: 事件监听机制中由事件源,事件,事件监听器三类对象组成 处理流程如下: Step 1:为某个事件源(组件)设置一个监听器,用于监听用户操作 St ...

  5. Java并发包同步工具之Exchanger

    前言 承接上文Java并发包同步工具之Phaser,讲述了同步工具Phaser之后,搬家博客到博客园了,接着未完成的Java并发包源码探索,接下来是Java并发包提供的最后一个同步工具Exchange ...

  6. 约束布局ConstraintLayout详解

    约束布局ConstraintLayout详解 转 https://www.jianshu.com/p/17ec9bd6ca8a 目录 1.介绍 2.为什么要用ConstraintLayout 3.如何 ...

  7. 由DBCursor的“can't switch cursor access methods”异常引发的思考

    先谈谈我是怎么用的: DBCollection dbcollection = XXXXXXXXXX(); //连接mongo DBCursor dbCursor = mergeVideoDB.find ...

  8. MATLAB学习(一)数组、变量、表达式、常用简单运算

    >> x=[1 2 3;4 5 6;7 8 9] x = 1 2 3 4 5 6 7 8 9 >> y=[1,2,3] y = 1 2 3 >> y=[1,2,3 ...

  9. localhost解释

    .localhost解释 localhost意思是只能从本地访问 比如说 kibana的配置文件里面写的是localhost,那就无法从浏览器访问到服务,必须写ip地址才可以从浏览器访问到

  10. Mybatis高级结果映射

    有时侯,我们用SQL取得的结果需要映射到类似Map<key, Bean>这样的数据结构中或是映射到多个实体类中时,我们就需要使用到resultMap.下面用3个例子说明Mybatis高级结 ...