浙大pat 1062题解
1061. Dating (20)
Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". It took him only a minute to figure out that those strange strings are actually referring to the coded time "Thursday 14:04" -- since the first common capital English letter (case sensitive) shared by the first two strings is the 4th capital letter 'D', representing the 4th day in a week; the second common character is the 5th capital letter 'E', representing the 14th hour (hence the hours from 0 to 23 in a day are represented by the numbers from 0 to 9 and the capital letters from A to N, respectively); and the English letter shared by the last two strings is 's' at the 4th position, representing the 4th minute. Now given two pairs of strings, you are supposed to help Sherlock decode the dating time.
Input Specification:
Each input file contains one test case. Each case gives 4 non-empty strings of no more than 60 characters without white space in 4 lines.
Output Specification:
For each test case, print the decoded time in one line, in the format "DAY HH:MM", where "DAY" is a 3-character abbreviation for the days in a week -- that is, "MON" for Monday, "TUE" for Tuesday, "WED" for Wednesday, "THU" for Thursday, "FRI" for Friday, "SAT" for Saturday, and "SUN" for Sunday. It is guaranteed that the result is unique for each case.
Sample Input:
3485djDkxh4hhGE
2984akDfkkkkggEdsb
s&hgsfdk
d&Hyscvnm
Sample Output:
THU 14:04
#include"iostream"
#include "algorithm"
#include "string"
#include <string.h>
#include<stdlib.h>
#include<stdio.h>
#include "vector"
using namespace std;
#define N 81
int main()
{
char w[7][4]={{"MON"},{"TUE"},{"WED"},{"THU"},{"FRI"},{"SAT"},{"SUN"}};
char s1[N],s2[N],s3[N],s4[N];
cin >> s1 >> s2 >> s3 >>s4;
int week,hour,mintute;
int i=0;
while(i<strlen(s1)&&i<strlen(s2))
{
if(s1[i]==s2[i]&&s1[i]>='A'&&s1[i]<='G')
{
week = s1[i]- 'A';
break;
}
i++;
}
i++;
while(i<strlen(s1)&&i<strlen(s2))
{
if(((s1[i]>='A'&&s1[i]<='N')||(s1[i]>='0'&&s1[i]<='9'))&&s1[i]==s2[i])
{
if(s1[i]>='A'&&s1[i]<='N')
{
hour = s1[i]-'A'+10;
break;
}
else if(s1[i]>='0'&&s1[i]<='9')
{
hour = s1[i]-'0';
break;
}
}
i++;
}
i=0;
while(i<strlen(s3)&&i<strlen(s4))
{
if(s3[i]==s4[i]&&((s3[i]>='A'&&s3[i]<='Z')||(s3[i]>='a'&&s3[i]<='z')))
{
mintute = i;
break;
}
i++;
}
printf("%s %02d:%02d\n",w[week],hour,mintute);
return 0;
}
浙大pat 1062题解的更多相关文章
- 浙大pat 1035题解
1035. Password (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To prepare f ...
- 浙大pat 1025题解
1025. PAT Ranking (25) 时间限制 200 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...
- 浙大pat 1011题解
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- 浙大PAT 7-06 题解
#include <stdio.h> #include <iostream> #include <algorithm> #include <math.h> ...
- 浙大pat 1012题解
1012. The Best Rank (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...
- 浙大 pat 1003 题解
1003. Emergency (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue As an emerg ...
- 浙大 pat 1038 题解
1038. Recover the Smallest Number (30) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...
- 浙大 pat 1047题解
1047. Student List for Course (25) 时间限制 400 ms 内存限制 64000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Y ...
- 浙大pat 1054 题解
1054. The Dominant Color (20) 时间限制 100 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard Behind the scen ...
随机推荐
- 挖坑:CF712E
#include<cstdio> #include<cstring> #include<algorithm> #define maxn 1000005 using ...
- C语言调用lua
在lua API中,调用一个函数的步骤很简单: 1.压入你要调用的函数,使用lua_getglobal. 2.压入调用参数. 3.使用lua_pcall 4.从栈中弹出结果. 举例说明,假设你有这 ...
- C++ 部分知识点
1,return语句返回函数的返回值,就是函数的类型,函数只能有唯一的返回值: return可以停止函数,并将控制返回主调函数: 一个函数可以有许多return语句,执行到哪个return语句,哪个起 ...
- 第一百二十三节,JavaScript错误处理与调试
JavaScript错误处理与调试 学习要点: 1.浏览器错误报告 2.错误处理 3.错误事件 4.错误处理策略 5.调试技术 6.调试工具 JavaScript在错误处理调试上一直是它的软肋,如果脚 ...
- Java 序列化 序列化与单例模式 [ 转载 ]
Java 序列化 序列化与单例模式 [ 转载 ] @author Hollis 本文将通过实例+阅读Java源码的方式介绍序列化是如何破坏单例模式的,以及如何避免序列化对单例的破坏. 单例模式,是设计 ...
- 递归——CPS(三)
JScript不是天然支持CPS,但是可以写一个分发引擎使得能工作在CPS风格下.一般只有一个活动的continuation,所以可以定义规则:JScript CPS 函数允许有返回,但是它们做的最后 ...
- mysql 时间类型分类
MySQL:MySQL日期数据类型.MySQL时间类型使用总结 MySQL 日期类型:日期格式.所占存储空间.日期范围 比较. 日期类型 存储空间 日期格式 日期范围------------ ---- ...
- css3制作3d旋转相册
此处只是记录,解析可见原文:http://www.cnblogs.com/skyblue-li/p/6092799.html <!DOCTYPE html> <html xmlns= ...
- C# 语言规范_版本5.0 (第8章 语句)
1. 语句 C# 提供各种语句.使用过 C 和 C++ 编程的开发人员熟悉其中大多数语句. statement: labeled-statement declaration-statement emb ...
- jetty启动https
<Configure id="Server" class="org.eclipse.jetty.server.Server"> <!-- if ...