GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com β€” πŸŽ‰ feat: initial commit for 1048 using java Β· liuchuo/PAT@7aef71a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • BasicLevel_Java
    • 1048 ζ•°ε­—εŠ ε―† (20 εˆ†).java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

β€ŽBasicLevel_Java/1048 ζ•°ε­—εŠ ε―† (20 εˆ†).javaβ€Ž

Copy file name to clipboard
+38Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import java.io.BufferedReader;
2+
import java.io.IOException;
3+
import java.io.InputStreamReader;
4+
5+
public class Main {
6+
final static char[] arr = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'J', 'Q', 'K'};
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9+
String[] str = br.readLine().split(" ");
10+
int len1 = str[0].length();
11+
int len2 = str[1].length();
12+
int max = Math.max(len1, len2);
13+
int min = Math.min(len1, len2);
14+
15+
String res = "";
16+
if (len1 < len2) {
17+
for (int i = 0 ; i < len2 - len1; i++) {
18+
str[0] = '0' + str[0];
19+
}
20+
}else {
21+
for (int i = 0 ; i < len1 - len2; i++) {
22+
str[1] = '0' + str[1];
23+
}
24+
}
25+
char[] c1 = str[0].toCharArray();
26+
char[] c2 = str[1].toCharArray();
27+
for (int i = max - 1; i >= 0; i--) {
28+
int index = max - i;
29+
if (index % 2 == 1) {
30+
res = arr[(c1[i] - '0' + c2[i] - '0') % 13] + res;
31+
}
32+
if (index % 2 == 0) {
33+
res = arr[(((c2[i] - '0') - (c1[i] - '0')) + 10) % 10] + res;
34+
}
35+
}
36+
System.out.println(res);
37+
}
38+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 β€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Γ—600. No cookies required.