#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;
}
1100pat
最新推荐文章于 2024-12-18 01:39:59 发布