美文网首页
1044 火星数字 (20 分)

1044 火星数字 (20 分)

作者: 79d12e22ec53 | 来源:发表于2019-05-19 15:32 被阅读0次
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <ctype.h>

    char *fire[13]={"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
    char *jinzhi[13]={"","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};

int Mars2Earth(char *s)
{
    int i;
    if(s)
    {
        for(i=0;i<13;i++)
        {
            if(strcmp(s,fire[i]) == 0)
                return i;
            if(strcmp(s,jinzhi[i]) == 0)
                return i*13;
        }
    }
}

int main()
{
    int k,n;
    int i;
    int flag;
    char buffer[100];

    scanf("%d",&n);

    for(i=0;i<=n;i++)
    {
        fgets(buffer,100,stdin);

        if(isdigit(buffer[0]))
        {
            k = atoi(buffer);
            if(k/13 == 0)
                printf("%s\n",fire[k%13]);
            if(k/13 >0)
                printf("%s %s\n",jinzhi[k/13],fire[k%13]);
        }

        if(isalpha(buffer[0]))
        {

            k = Mars2Earth(strtok(buffer, " \n"));

            k += Mars2Earth(strtok(NULL, " \n"));

            printf("%d\n", k);
        }

    }


    return 0;
}


相关文章

网友评论

      本文标题:1044 火星数字 (20 分)

      本文链接:https://www.haomeiwen.com/subject/stlqzqtx.html