2020-04-09

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<string>
using namespace std;
int min(int a,int b){
    int temp = a;
    if(a>b){
        temp = b;
    }
    return temp;    
}
int main(){
    string day[7] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
    string str1,str2,str3,str4;
    cin>>str1>>str2>>str3>>str4;
    int l1 = str1.length();
    int l2 = str2.length();
    int l3 = str3.length();
    int l4 = str4.length();
    int min1 = max(l1,l2);
    int min2 = max(l3,l4);
    char arr_str[2];
    int i=0;
    for(i;i<min1;++i){
        if(str1[i]==str2[i]&&str1[i]>='A'&&str1[i]<='G'){
            arr_str[0] = str1[i];
            break;
        }
    }
    i++;
    for(i;i<min1;++i){
        if(str1[i]==str2[i]&&str1[i]>='A'&&str1[i]<='N' || str1[i]==str2[i]&&isdigit(str1[i])){
            arr_str[1] = str1[i];
            break;
        }
    }
    int min;
    for(int i=0;i<min2;++i){
        if(str3[i]==str4[i]&&isalpha(str3[i])){
            min = i;
            break;  
        }
    }
    int hour = isdigit(arr_str[1]) ? arr_str[1] - '0' : arr_str[1] - 'A' + 10;
    cout<<day[arr_str[0]-'A']<<" ";
    printf("%02d:%02d",hour,min);
    return 0;
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末召锈,一起剝皮案震驚了整個(gè)濱河市颊乘,隨后出現(xiàn)的幾起案子协怒,更是在濱河造成了極大的恐慌荣堰,老刑警劉巖桑嘶,帶你破解...
    沈念sama閱讀 218,451評(píng)論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異晦溪,居然都是意外死亡夭拌,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,172評(píng)論 3 394
  • 文/潘曉璐 我一進(jìn)店門恒序,熙熙樓的掌柜王于貴愁眉苦臉地迎上來瘦麸,“玉大人,你說我怎么就攤上這事歧胁∽趟牵” “怎么了?”我有些...
    開封第一講書人閱讀 164,782評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵喊巍,是天一觀的道長屠缭。 經(jīng)常有香客問我,道長崭参,這世上最難降的妖魔是什么呵曹? 我笑而不...
    開封第一講書人閱讀 58,709評(píng)論 1 294
  • 正文 為了忘掉前任,我火速辦了婚禮何暮,結(jié)果婚禮上奄喂,老公的妹妹穿的比我還像新娘。我一直安慰自己海洼,他們只是感情好跨新,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,733評(píng)論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著坏逢,像睡著了一般域帐。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上词疼,一...
    開封第一講書人閱讀 51,578評(píng)論 1 305
  • 那天俯树,我揣著相機(jī)與錄音,去河邊找鬼贰盗。 笑死许饿,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的舵盈。 我是一名探鬼主播陋率,決...
    沈念sama閱讀 40,320評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼秽晚!你這毒婦竟也來了瓦糟?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,241評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤赴蝇,失蹤者是張志新(化名)和其女友劉穎菩浙,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,686評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡劲蜻,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,878評(píng)論 3 336
  • 正文 我和宋清朗相戀三年陆淀,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片先嬉。...
    茶點(diǎn)故事閱讀 39,992評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡轧苫,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出疫蔓,到底是詐尸還是另有隱情含懊,我是刑警寧澤,帶...
    沈念sama閱讀 35,715評(píng)論 5 346
  • 正文 年R本政府宣布衅胀,位于F島的核電站岔乔,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏拗小。R本人自食惡果不足惜重罪,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,336評(píng)論 3 330
  • 文/蒙蒙 一樱哼、第九天 我趴在偏房一處隱蔽的房頂上張望哀九。 院中可真熱鬧,春花似錦搅幅、人聲如沸阅束。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,912評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽息裸。三九已至,卻和暖如春沪编,著一層夾襖步出監(jiān)牢的瞬間呼盆,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,040評(píng)論 1 270
  • 我被黑心中介騙來泰國打工蚁廓, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留访圃,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,173評(píng)論 3 370
  • 正文 我出身青樓相嵌,卻偏偏與公主長得像腿时,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子饭宾,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,947評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容

  • pyspark.sql模塊 模塊上下文 Spark SQL和DataFrames的重要類: pyspark.sql...
    mpro閱讀 9,456評(píng)論 0 13
  • Chapter 1 In the year 1878, I took my degree of Doctor of...
    foxgti閱讀 3,683評(píng)論 0 6
  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc閱讀 2,860評(píng)論 0 0
  • By clicking to agree to this Schedule 2, which is hereby ...
    qaz0622閱讀 1,457評(píng)論 0 2
  • 今天這篇和饅頭有關(guān)批糟。 不知道各位觀眾老爺對(duì)點(diǎn)了紅點(diǎn)的饅頭有沒有印象?小時(shí)候一直不知道為什么要在饅頭上點(diǎn)個(gè)紅點(diǎn)看铆,自從...
    從火星看地球閱讀 684評(píng)論 0 0