Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Basic/Java] 1044, 1046, 1047, 1048 #107

Merged
merged 4 commits into from
Apr 27, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
🎉 feat: initial commit for 1044 using java
  • Loading branch information
totalo committed Apr 27, 2019
commit 9e341f971210d5667198f02aad2b54319ad3cf81
65 changes: 65 additions & 0 deletions BasicLevel_Java/1044 火星数字 (20 分).java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
static String[] e = {"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
static String[] a = {"", "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};



public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
for (int i = 0; i < n; i++) {
String str = br.readLine();
char[] chars = str.toCharArray();
if (chars[0] >= '0' && chars[0] <= '9') {
eToa(Integer.parseInt(str));

}else {
System.out.println(aToe(str));
}
}

}

// ������ת����
private static int aToe(String str){
int result = 0;
String low = str.substring(str.length() - 3);
for (int i = 0; i < 13; i++) {
if (e[i].equals(low)) {
result += i;
break;
}
else if (a[i].equals(low)) {
result += (i*13);
break;
}
}
if (str.length() > 4) {
for (int i = 0; i < 13; i++) {
if (a[i].equals(str.substring(0,3))) {
result += i * 13;
break;
}
}
}
return result;
}

// ����ת������
private static void eToa(int res){
if (res/13 != 0)
System.out.print(a[res/13]);
if (res / 13 != 0 && res % 13 != 0)
System.out.print(" " + e[res % 13]);
if (res/13 == 0)
System.out.print(e[res % 13]);
System.out.println();
}

}