/*
12
0
10
168
9
39
jan
tam
tam jan
jou dec
dec
tret jan
tret tam
tret
oct
jou dec
sep
maa
1
13
14
168
12
1
13
*/
#include<stdio.h>
#include<string.h>
int issame(char a[],char b[]){//判斷首地址為a,b,的兩個字串是否相等
for(int i=0;i<3;i++){
if(a[i]!=b[i])return 0;
}
return 1;
}
void printint(int a,int i){//將整型數字用火星文輸出
char c1[12][4]={"jan", "feb", "mar", "apr","may" ,"jun" , "jly","aug" ,"sep" , "oct", "nov", "dec"};
char c2[12][4]={"tam","hel" ,"maa" , "huh", "tou","kes" , "hei", "elo", "syy", "lok", "mer", "jou"};
if(i==1){
for(int i=0;i<3;i++){
putchar(c1[a-1][i]);
}
}
else {
for(int i=0;i<3;i++){
putchar(c2[a-1][i]);
}
}
}
void marstoearth(char a[]){
char c1[12][4]={"jan", "feb", "mar", "apr","may" ,"jun" , "jly","aug" ,"sep" , "oct", "nov", "dec"};
char c2[12][4]={"tam","hel" ,"maa" , "huh", "tou","kes" , "hei", "elo", "syy", "lok", "mer", "jou"};
int len=strlen(a),x=0,y=0;
char c[5]={"tret"};
if(issame(c,a)){
for(int i=0;i<13;i++){
if(issame(c2[i],a+5))x=(i+1)*13;
if(issame(c1[i],a+5))x=i+1;
}
if(!x)printf("0\n");
else printf("%d\n",x);
}
else {
if(len>3){
for(int i=0;i<13;i++){
if(issame(c2[i],a+0))y=(i+1)*13;
if(issame(c1[i],a+4))x=i+1;
}
}
else{
for(int i=0;i<13;i++){
if(issame(c1[i],a))x=i+1;
}
}
printf("%d\n",y+x);
}
}
void earthtomars(char a[]){//數字字串轉化為火星文 再輸出
int len=strlen(a);
int n=0,b[2]={0,0};
for(int i=0;i<len;i++){
n=n*10+a[i]-'0';
}
b[0]=n/13;
b[1]=n%13;
if(b[0]){
printint(b[0],2);printf(" ");
printint(b[1],1);printf("\n");
}
else{
printint(b[1],1);printf("\n");
}
}
int main(){
int n;
scanf("%d",&n);
char a[n][10];
for(int i=0;i<=n;i++){
gets(a[i]);
}
for(int i=1;i<=n;i++){
if(*a[i]>'0'&&*a[i]<='9')earthtomars(a[i]);
else if(*a[i]=='0')printf("tret\n");
else marstoearth(a[i]);
}
}
uj5u.com熱心網友回復:
沒仔細看你代碼,我也遇到,看了其他博客發現,:火星文的13只是一個tam,26只是一個hel!!!!uj5u.com熱心網友回復:
樓上說的是對的,你的代碼里面13的倍數沒有考慮。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/97354.html
標籤:C++ 語言
上一篇:小白求解,不懂。。
下一篇:定時器
