Algorithm


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

Code Examples

#1 UVA Online Judge solution 300 using C, C++

Code - C Programming


#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;
}
Copy The Code & Try With Live Editor
Advertisements

Demonstration


UVA Online Judge solution 300 - Maya Calendar Solution in C, C++

 

Tags: UVA solution, UVA online judge, uva 300, uva 300 maya calendar solution

Previous
UVA Online Judge solution -11088 - End up with More Teams - UVA Online Judge solution in C,C++,java