-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1044.c
56 lines (52 loc) · 1.38 KB
/
1044.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
char fir[][14] = {"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
char sec[][13] = {"tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
int Mars2Earth(char s[])
{
if(s)
{
for(int i = 0; i < 13; i++)
if(strcmp(s, fir[i]) == 0)
return i;
for(int i = 1; i < 13; i++)
if(strcmp(s, sec[i - 1]) == 0)
return i * 13;
}
return 0;
}
int main()
{
int n;
char ch[10];
scanf("%d", &n);
getchar();
for(int i = 0; i < n; i++){
gets(ch);
if(isalpha(ch[0])){
int result = 0;
result += Mars2Earth(strtok(ch, " \n"));
result += Mars2Earth(strtok(NULL, "\n"));
printf("%d\n", result);
}else{
int num = 0, j = 0;
while(ch[j]){
num = num * 10 + ch[j] - '0';
j++;
}
if((num / 13) != 0){
printf("%s", sec[(num / 13) - 1]);
if((num % 13) == 0){
printf("\n");
continue;
}else{
printf(" ");
}
}
printf("%s\n", fir[num % 13]);
}
}
return 0;
}