1014 福尔摩斯的约会 (20 分)

注意
DAY:扫描第一对相同的大写字母A~G
HH: 在扫描到DAY之后,再扫描第一对是数字和大写字母A~N的字符
MM:扫描相同英文字符

#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <cstdio>
#include <unordered_map>
#include <algorithm>
using namespace std;
int main(){
	string s1, s2, s3, s4;
	unordered_map<char, string> mp;
	mp['A'] ="MON";
	mp['B'] ="TUE";
	mp['C'] ="WED";
	mp['D'] ="THU";
	mp['E'] ="FRI";
	mp['F'] ="SAT";
	mp['G'] ="SUN";
	
	cin>>s1>>s2>>s3>>s4;
	char week, hour;
	int minute;
	int cnt = 0;
	bool tag = false;
	for(int i = 0; i < s1.size() && i < s2.size(); i++){
		if(s1[i] >= 'A' && s1[i] <= 'G' && s1[i] == s2[i] && !tag){
			week = s1[i];
			tag = true;
			continue;
		}
		if(tag && s1[i] == s2[i] && (isdigit(s1[i])|| s1[i] >= 'A' && s1[i] <= 'N')){
			hour = s1[i];
			break;
		}
	}
	
	for(int i = 0; i < s3.size() && i < s4.size(); i++){
		if(s3[i] == s4[i]&& isalpha(s3[i])) {
			minute = i;
			break;
		}
	}
	int h = isdigit(hour) ? hour - '0' : hour - 'A' + 10;
	cout<<mp[week]<<" ";
	printf("%02d:%02d\n", h, minute);
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值