• 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<cstdio>
    #include<cstring>
    using namespace std;
    int main(){
    	char a[62],b[62],c[62],d[62];
    	char s[8][4]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
    	scanf("%s%s%s%s",a,b,c,d);
    	int dd;
    	char h;
    	int hh;
    	int m;
    	int i,j;
    	int len=strlen(a);
    	int index1=-1,index2=-1;
    	for(i=0;i<len;i++){
    		if(a[i]==b[i]){
    			if(index1==-1&&(a[i]>='A'&&a[i]<='G')){
    				index1=i;
    			}else if(index1!=-1&&index2==-1&&((a[i]>='A'&&a[i]<='N'||a[i]>='0'&&a[i]<='9'))){
    				index2=i;
    				break;
    			}
    		}
    	}
    	if(a[index1]>='A'&&a[index1]<='G'){
    		dd=a[index1]-'A';
    	}
    	h=b[index2];
    	if(h>='0'&&h<='9'){
    		hh=h-'0';
    	}else if(h>='A'&&h<='N'){
    		hh=h-'A'+10;
    	}
    	len=strlen(c);
    	int index=0;
    	for(i=0;i<len;i++){
    		if(c[i]==d[i]&&(c[i]>='A'&&c[i]<='Z'||c[i]>='a'&&c[i]<='z')){
    			index=i;
    			break;
    		}
    	}
    	printf("%s %02d:%02d
    ",s[dd],hh,index);
    	return 0;
    } 
    

      

  • 相关阅读:
    20162328蔡文琛 四则运算第一周
    实验三:实验报告
    20162328蔡文琛week09
    20162328蔡文琛week08
    20162328蔡文琛week07
    实验报告二
    20162312张家铖 10.9查找课堂测试
    20162312实验一
    # 20162312 2017-2018-3 《程序设计与数据结构》第3周学习总结
    # 20162312 2017-2018-1 《程序设计与数据结构》第1周学习总结
  • 原文地址:https://www.cnblogs.com/grglym/p/7821274.html
Copyright © 2020-2023  润新知