#29065: Java 解(如果有更快的,歡迎分享)


wer12369qaz15963@gmail.com (dentr)

學校 : 新北市立清水高中
編號 : 174903
來源 : [134.208.49.24]
最後登入時間 :
2024-11-21 18:28:16
a054. 電話客服中心 -- 板橋高中教學題 | From: [219.84.98.239] | 發表日期 : 2022-01-26 16:22

解題思路: 先找出前面8碼的總和  以及 檢查碼 再用在公式裡 然後數字一一對照看哪個是可以用再公式裡 再轉成字母  

 

沒打過的,先打一下真的不會再看

 

 

程式碼: 

 

import java.util.Scanner;

public class a054 {
public static void main (String[] args){
Scanner input = new Scanner(System.in);
while(input.hasNext()){
String a = input.next();
check_number(Character.getNumericValue(a.charAt(8)),eight_number(a.substring(0,9).toCharArray()));
System.out.println("");



}
}

public static void check_number (int a, int b) {
int[] number = {10,11,12,13,14,15,16,17,34,18,19,20,21,22,35,23,24,25,26,27,28,29,32,30,31,33};
String[] ABC = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
int x=0;
if (a==0){a=10;};
for (int i=0;i<number.length;i++) {
if (-((number[i] % 10 * 9) + (number[i] / 10) + b) % 10 == a-10) {
System.out.print(ABC[i]);
}
}
}
public static int eight_number (char[] a){
int result=0;
int e =8;
for(int i=0;i<a.length;i++){
result += Character.getNumericValue(a[i])*e;
e--;

}
return result;
}
}
 
ZeroJudge Forum