1061 Dating (20 point(s)

本菜少见的一次提交ac。。。
1061 Dating

#include 
#include 
#include 

#define N 101
using namespace std;
const char weekday[7][4] = {
        "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"
};

int main() {
    int day = 0, len1, len2, hh = 0, mm = 0;
    char line1[N], line2[N], line3[N], line4[N];
    scanf("%s%s%s%s", line1, line2, line3, line4);
    len1 = min(strlen(line1), strlen(line2));
    len2 = min(strlen(line3), strlen(line4));
    int i = 0;
    for (; i < len1; ++i) {
        if (line1[i] >= 'A' && line1[i] <= 'G' && line1[i] == line2[i]) {
            day = line1[i] - 'A';
            break;
        }
    }
    for (++i; i < len1; ++i) {
        if (line1[i] == line2[i]) {
            if (line1[i] >= 'A' && line1[i] <= 'N') {
                hh = line1[i] - 'A' + 10;
                break;
            }
            if (line1[i] >= '0' && line1[i] <= '9') {
                hh = line1[i] - '0';
                break;
            }
        }
    }
    for (int j = 0; j < len2; ++j) {
        if (line3[j] == line4[j] &&
            ((line3[j] >= 'a' && line3[j] <= 'z') ||
             (line3[j] >= 'A' && line3[j] <= 'Z'))) {
            mm = j;
            break;
        }
    }
    printf("%s %02d:%02d", weekday[day], hh, mm);
    return 0;
}

你可能感兴趣的:(1061 Dating (20 point(s))