UVA Solution 300 - Maya Calendar Solution in C, C++ | Volume 3 - Online Judge Solution

Latest

It is a free Online judges problems solution list. Here you can find UVA online Judge Solution, URI Online Judge Solution, Code Marshal Online Judge Solution, Spoz Online Judge Problems Solution

Friday, May 5, 2017

UVA Solution 300 - Maya Calendar Solution in C, C++ | Volume 3

UVA Solution 300 - Maya Calendar Solution in C, C++ | Volume 3


UVA Online Judge Solution 300 - Maya Calendar | Volume 2
UVA Problem Link - https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=236

Problem Name: 300 - Maya Calendar
Problem Number : UVA - 300 - Maya Calendar
Online Judge : UVA Online Judge Solution
Volume: 2
Solution Language : C, C plus plus

UVA Solution 300 - Maya Calendar Code in C, CPP:


#include <stdio.h>
#include <string.h>
int getNum(char s[]) {
    static const char m[][20] = {
        "pop", "no", "zip", "zotz", "tzec",
        "xul", "yoxkin", "mol", "chen", "yax",
        "zac", "ceh", "mac", "kankin", "muan",
        "pax", "koyab", "cumhu", "uayet"
    };
    int i;
    for(i = 0; ; i++)
        if(!strcmp(m[i], s))
            return i;
}
int main() {
    const char D[][20] = {
        "imix", "ik", "akbal", "kan", "chicchan",
        "cimi", "manik", "lamat", "muluk", "ok",
        "chuen", "eb", "ben", "ix", "mem", "cib",
        "caban", "eznab", "canac", "ahau"
    };
    int t;
    scanf("%d", &t);
    printf("%d\n", t);
    while(t--) {
        int DD, YY;
        char MM[30];
        scanf("%d. %s %d", &DD, MM, &YY);
        int tot;
        tot = YY*365 + getNum(MM)*20 + DD;
        printf("%d %s %d\n", tot%13+1, D[tot%20], tot/260);
    }
    return 0;
}

No comments:

Post a Comment