1100pat

#include<stdio.h>
#include<string.h>
char* lower[] = {"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec"};
char* higher[] = {"empty","tam","hel","maa","huh","tou","kes","hei","elo","syy","lok","mer","jou"};
void num_to_alpha(char* from,char* to)
{
        int itemp;
        sscanf(from,"%d",&itemp);
//      printf("debug,itemp %d\n",itemp);
        if(itemp/13)
        {
                memcpy(to,higher[itemp/13],3);
                memcpy(&to[3]," ",1);
                memcpy(&to[4],"\0",1);
                strcat(to,lower[itemp%13]);
        }else{
                memset(to,0,10);
//              memcpy(to,lower[itemp],3);
//              memcpy(&to[3],"\0",1);
                strcat(to,lower[itemp]);
        }
//              printf("debug to = %s\n",to);
}

void alpha_to_num(char* from,char* to)
{
        int i = 0,j = 0;
        if(strlen(from)>4)
        {
//              printf("flag\n");
                while(memcmp(from,higher[j],3))
                        {j++;
                        if(j >12){j=0; break;}
                        }
                while(memcmp(&from[4],lower[i],3))
                        {i++;
                        if(i >12){i=0; break;}
                        }
        }else{
                while(memcmp(from,higher[j],3))
                        {j++;
                        if(j >12){j=0; break;}
                        }
                while(memcmp(from,lower[i],3))
                        {i++;
                        if(i >12){i=0; break;}
                        }
        }
//      printf("debug j %d,i %d\n",j,i);
//      printf("total = %d\n",j*13+i);
        sprintf(to,"%d",j*13+i);

}



int main()
{
        int count,i;
        char temp[100][10];
        char result[100][10];
        fgets(temp[0],10,stdin);
        sscanf(temp[0],"%d",&count);
//      printf("count = %d\n",count);
        fflush(stdin);
        for(i = 0; i < count; i++)
        {
                fgets(temp[i],10,stdin);
                        if(('0' <= temp[i][0]) &&(temp[i][0] <= '9')){
                                num_to_alpha(temp[i],result[i]);
//                              printf("it is number %s\n",result[i]);
                        }else{
                                alpha_to_num(temp[i],result[i]);
//                              printf("it is alphabet %s\n",result[i]);
                        }

//                      printf("i =%d  %s\n",i,temp[i]);
        }
        for(i = 0; i < count; i++)
        {
                printf("%s\n",result[i]);

        }

        return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值