1061. Dating (20)

来源:互联网 发布:中小型网络拓扑及搭建 编辑:程序博客网 时间:2024/06/01 07:27

1061. Dating (20)

时间限制
150 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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

提交代码

题目意思:

给定四个字符串,前面两个字符串包含day和hour两个信息,后面两个字符串包含minute信息。

前两个字符串的第一对相同位置的A-G大写字母表示day、A-G表示星期一到星期天。day位置后的第一对0-9或A-N的字符表示hour,从0到23。后两个字符串的第一对相同位置的英文字母表示minute。

#include <iostream>#include <cstdio>using namespace std;int main(){    char s[4][70];    int hour, minate;    for(int i = 0; i < 4; i++)        cin >> s[i];    int flag1 = 0,flag2 = 0;    for(int i = 0; s[0][i]!='\0'&&s[1][i]!='\0';i++)    {        if(s[0][i] == s[1][i]&&flag1==0&&s[0][i]>='A'&&s[0][i]<='G')        {            flag1 = 1;            flag2 = 1;            if(s[0][i] == 'A')                cout << "MON ";            if(s[0][i] == 'B')                cout << "TUE ";            if(s[0][i] == 'C')                cout << "WED ";            if(s[0][i] == 'D')                cout << "THU ";            if(s[0][i] == 'E')                cout << "FRI ";            if(s[0][i] == 'F')                cout << "SAT ";            if(s[0][i] == 'G')                cout << "SUN ";            continue;        }        if(s[0][i] == s[1][i]&&flag2==1)        {            if(s[0][i]>='0'&&s[0][i]<='9')            {                printf("%02d:",s[0][i]-'0');                break;            }            if(s[0][i]>='A'&&s[0][i]<='N')            {                printf("%02d:",s[0][i]-55);                break;            }        }    }    for(int i = 0; s[2][i]!='\0'&&s[3][i]!='\0';i++)    {        if(s[2][i] == s[3][i]&&((s[2][i]>=65&&s[2][i]<=90)||(s[2][i]>=97&&s[2][i]<=122)))        {            printf("%02d", i);            break;        }    }    return 0;}


原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 快压解压文件在电脑上打不开怎么办 虎牙直播刺激战场观看有延迟怎么办 登录页面点击登录窗口关不了怎么办 h5中的摇晃手机在电脑端怎么办 忘记手机锁屏密码怎么办4g qq最早绑定的号码忘记了怎么办 重启路由器之后宽带连接不上怎么办 微信授权小程序总是不行怎么办 微信把钱转到别人账户里了怎么办 微信转到对方账户停用了怎么办 微信号被认为是投票水军怎么办 微信投票时显示账号异常怎么办 京东商城买东西老不到货怎么办 优酷投屏一会就会出现花报怎么办 苹果手机的app安卓找不到怎么办 微信网页获取用户信息点了否怎么办 淘宝卖家退发货信息选择错了怎么办 法宣在线出现在其他地方登陆怎么办 QQ被冻结又不知道申诉资料怎么办 开通优酷会员了再开酷喵会员怎么办 考的不好时别人问你多少分时怎么办 订了产品一直收不到货怎么办 微信零钱提现忘记密码怎么办 微信里面的零钱忘记密码怎么办 微信的零钱密码丢了怎么办 微信公众号被屏蔽了所有功能怎么办 刚开淘宝店没信誉要怎么办 如果发现货品有问题商家不换怎么办 文件夹里面的图片怎么拖不动怎么办 网赌系统维护审核就不给提款怎么办 客户说我卖的东西是假货怎么办 微信小程序第三方平台倒闭了怎么办 金立手机锁屏密码忘了怎么办 不知道微信账号的公众号密码怎么办 微信公众号充话费充错号码怎么办 蜻蜓商城三天免流业务退不了怎么办 日上免税店提货日期写错了怎么办 微信公众平台账号名密码忘了怎么办 有人扬言要搞垮我的店铺怎么办 招行信用卡签到积分未领取怎么办 怎么办照片发送到邮微信箱里去