PAT 1061. Dating

题是别人出的,不按她的想法来也没办法,真心想k一顿

#include <cstdio>
#include <cstdlib>

using namespace std;

const char*  days[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};

inline bool is_cap_alpha(char ch) {
    return ch >= ‘A‘ && ch <= ‘Z‘;
}

inline bool is_alpha(char ch) {
    return ch >= ‘a‘ && ch <= ‘z‘ || ch >= ‘A‘ && ch <= ‘Z‘;
}

int main() {
    char a[64] = {0};
    char b[64] = {0};
    char c[64] = {0};
    char d[64] = {0};

    scanf("%s", a);
    scanf("%s", b);
    scanf("%s", c);
    scanf("%s", d);

    int i = 0, j= 0;
    char day = -1;
    char hour= 0;
    char min = 0;
    char ta, tb;
    while ((ta = a[i++]) != ‘\0‘ && (tb = b[j++]) != ‘\0‘) {
        if (ta != tb) {
            continue;
        }
        if (is_cap_alpha(ta)) {
            if (day == -1) {
                // range check
                if (ta <= ‘G‘) {
                    day = ta - ‘A‘;
                }
            } else if (ta <= ‘N‘){
                hour = ta - ‘A‘ + 10;
                break;
            }
        } else if (day != -1 && ta >= ‘0‘ && ta <= ‘9‘){
            hour = ta - ‘0‘;
            break;
        }
    }
    i = 0, j = 0;
    while ((ta = c[i]) != ‘\0‘ && (tb = d[j]) != ‘\0‘) {
        if (ta == tb && is_alpha(ta)) {
            min = i;
            break;
        }
        i++, j++;
    }
    printf("%s %02d:%02d\n", days[day], hour, min);

    return 0;
}
时间: 2024-12-30 01:17:22

PAT 1061. Dating的相关文章

PAT 1061. Dating (20)

1 #include <iostream> 2 #include <string> 3 4 using namespace std; 5 6 int main() 7 { 8 string s1, s2, s3, s4; 9 cin >> s1 >> s2 >> s3 >> s4; 10 string day[7]{"MON", "TUE", "WED", "THU

PAT 1061. 判断题

PAT 1061. 判断题 判断题的评判很简单,本题就要求你写个简单的程序帮助老师判题并统计学生们判断题的得分. 输入格式: 输入在第一行给出两个不超过100的正整数N和M,分别是学生人数和判断题数量.第二行给出M个不超过5的正整数,是每道题的满分值.第三行给出每道题对应的正确答案,0代表"非",1代表"是".随后N行,每行给出一个学生的解答.数字间均以空格分隔. 输出格式: 按照输入的顺序输出每个学生的得分,每个分数占一行. 输入样例: 3 6 2 1 3 3 4

PAT (Advanced Level) 1061. Dating (20)

简单模拟. #include<stdio.h> #include<string.h> char s1[70],s2[70],s3[70],s4[70]; char f[7][5]={"MON ", "TUE ","WED ","THU ","FRI ","SAT ","SUN "}; int a,b,c,flag; int main() { s

1061. Dating

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 &

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:0

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:0

1061. Dating (20)

1 #include <stdio.h> 2 #include <map> 3 #include <string.h> 4 #include <ctype.h> 5 using namespace std; 6 int main() 7 { 8 map<char,int> ToHour; 9 int i; 10 for(i=0;i<=9;i++) 11 ToHour['0'+i]=i; 12 for(i='A';i<='N';i++)

PAT甲级题分类汇编——线性

线性类,指线性时间复杂度可以完成的题.在1051到1100中,有7道: 题号 标题 分数 大意 时间 1054 The Dominant Color 20 寻找出现最多的数 200ms 1061 Dating 20 寻找字符串中相同字符 200ms 1071 Speech Patterns 25 寻找出现最多的单词 300ms 1077 Kuchiguse 20 字符串共同后缀 150ms 1082 Read Number in Chinese 25 中文读数 400ms 1084 Broken

pat1061. Dating (20)

1061. Dating (20) 时间限制 50 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 minut