PAT 1014 福爾摩斯的約會

2021-10-11 10:21:09 字數 1860 閱讀 4040

大偵探福爾摩斯接到一張奇怪的字條:我們約會吧! 3485djdkxh4hhge 2984akdfkkkkggedsb s&hgsfdk d&hyscvnm。大偵探很快就明白了,字條上奇怪的亂碼實際上就是約會的時間星期四 14:04,因為前面兩字串中第 1 對相同的大寫英文本母(大小寫有區分)是第 4 個字母 d,代表星期四;第 2 對相同的字元是 e ,那是第 5 個英文本母,代表一天裡的第 14 個鐘頭(於是一天的 0 點到 23 點由數字 0 到 9、以及大寫字母 a 到 n 表示);後面兩字串第 1 對相同的英文本母 s 出現在第 4 個位置(從 0 開始計數)上,代表第 4 分鐘。現給定兩對字串,請幫助福爾摩斯解碼得到約會的時間。

輸入格式:

輸入在 4 行中分別給出 4 個非空、不包含空格、且長度不超過 60 的字串。

輸出格式:

在一行中輸出約會的時間,格式為 day hh:mm,其中 day 是某星期的 3 字元縮寫,即 mon 表示星期一,tue 表示星期二,wed 表示星期三,thu 表示星期四,fri 表示星期五,sat 表示星期六,sun 表示星期日。題目輸入保證每個測試存在唯一解。

輸入樣例:

3485djdkxh4hhge 

2984akdfkkkkggedsb

s&hgsfdk

d&hyscvnm

輸出樣例:

thu 14:04
#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

using

namespace std;

const

int inf =

0x3f3f3f3f

;typedef

long

long ll;

const

double pi =

3.1415926535

;int

main()

; string s1, s2, s3, s4;

cin >> s1 >> s2 >> s3 >> s4;

int count =0;

int hh =

0, mm =

0, day =0;

for(

int i =

0; i <

min(s1.

size()

, s2.

size()

); i++)if

(count ==

1&& s1[i]

== s2[i]&&(

isdigit

(s1[i])||

(s1[i]

>=

'a'&&s1[i]

<=

'n')))

}for

(int i =

0; i <

min(s3.

size()

, s4.

size()

); i++)}

cout << date[day]

<<

" ";

printf

("%02d:%02d\n"

, hh, mm)

;return0;

}

PAT 1014 福爾摩斯的約會

大偵探福爾摩斯接到一張奇怪的字條 我們約會吧!3485djdkxh4hhge 2984akdfkkkkggedsb s hgsfdk d hyscvnm 大偵探很快就明白了,字條上奇怪的亂碼實際上就是約會的時間 星期四 14 04 因為前面兩字串中第1對相同的大寫英文本母 大小寫有區分 是第4個字母...

PAT 1014 福爾摩斯的約會

char week table 7 3 就行了 定義成二維陣列儲存時可以簡單看作一排乙個字串陣列 const char week table 7 這樣是定義了乙個指標陣列 指標元素分別指向每乙個對應的字串儲存的首位址 include include int main void char str1 6...

PAT 1014 福爾摩斯的約會

時間限制 100 ms 記憶體限制 65536 kb 長度限制 8000 b 判題程式 standard 作者 chen,yue 大偵探福爾摩斯接到一張奇怪的字條 我們約會吧!3485djdkxh4hhge 2984akdfkkkkggedsb s hgsfdk d hyscvnm 大偵探很快就明白...