Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

让玛雅历算出来的day从0开始就好了

Posted by zjcf at 2017-12-18 20:57:27 on Problem 1008
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

char myM[19][10] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet"};
char hoW[20][10] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};


int getMyM(char* m) {
    for (int i=0; i<19; i++){
        if(strcmp(myM[i], m) == 0){
            return i;
        }
    }
}


int main()
{
    int testCase;
    int myDay, myYear, hoDay, hoMon, hoYear, day;
    char myMonth[10];
    scanf("%d", &testCase);
    printf("%d\n", testCase);
    while(testCase--) {
        scanf("%d. %s %d", &myDay, myMonth, &myYear);
        day = 365 * myYear + myDay + 20 * getMyM(myMonth);
        hoDay = 1 + day%13;
        hoMon = day%20;
        hoYear = day/260;
        printf("%d %s %d\n", hoDay, hoW[hoMon], hoYear);
    }

     return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator