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

poj1008:为什么一直都是wrong answer

Posted by lianguan at 2016-08-27 16:28:03
//
//  poj1008.c
//  test
//
//  Created by abc on 16/8/27.
//  Copyright © 2016年 abc. All rights reserved.
//

#include <stdio.h>
#include <string.h>
struct R{
    int num;
    char *day;
    int year;
};
int main()
{
    struct R result[500];
    char Haab_Month[19][10]={"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu"};
    char Tzolkin[20][10]={"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"};
    int n;
    scanf("%d",&n);
    for(int count=0;count<n;count++)
    {
        int day,year;
        char month[10];
        int tolal_days=0;
        int current_month;
        
        scanf("%d.%s%d",&day,month,&year);
        for(int y=0;y<19;y++)
        {
            if(strcmp(Haab_Month[y], month)==0)
            {
                current_month=y+1;
                break;
            }
        }
        tolal_days=year*365+20*(current_month-1)+(day+1);
        int Tzolkin_Year= tolal_days/260;
        int Tzolkin_day = (tolal_days%260)%20;
        int Tzolkin_num = (tolal_days%260)%13+1;
        char *Tzolkin_str = Tzolkin[Tzolkin_day-1];

        result[count].num=Tzolkin_num;
        result[count].day=Tzolkin_str;
        result[count].year=Tzolkin_Year;
    }
    printf("%d\n",n);
    for(int count=0;count<n;count++){
        printf("%d %s %d\n",result[count].num-1,result[count].day,result[count].year);
    }
    return 1;
}

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