#18401: 簡易方法,可以跑,但RE,歡迎指正


a43913072@gmail.com (陳芃)

學校 : 國立暨南國際大學
編號 : 86383
來源 : [219.68.215.178]
最後登入時間 :
2019-06-25 20:44:12
a054. 電話客服中心 -- 板橋高中教學題 | From: [219.68.215.178] | 發表日期 : 2019-07-09 23:10

public class a054 {
public static void main(String[] args) {
java.util.Scanner scanner = new java.util.Scanner(System.in);
while(scanner.hasNext()) {
String[] as= {"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[] num= { 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};
int[] nn= {8,7,6,5,4,3,2,1};
int sum=0; //少前兩碼的總和
int sum1=0; //正確總和
int avg=0;
for(int i=0;i<9;i++) {
int r=scanner.nextInt();
if(i != 8) {
sum=sum+r*nn[i];
}else {
avg=10-r;
}
}
for(int i=0;i<25;i++) {
if(((num[i]%10)*9+(num[i]/10)+sum)%10==avg) {
System.out.print(as[i] );
}else {
continue;
}
}
}}
}

 
#20135: Re:簡易方法,可以跑,但RE,歡迎指正


z85385637 (M-Kai)

學校 : 樹德科技大學
編號 : 96081
來源 : [180.218.46.214]
最後登入時間 :
2022-10-13 21:14:12
a054. 電話客服中心 -- 板橋高中教學題 | From: [120.119.33.43] | 發表日期 : 2019-12-05 22:40

public class a054 {
public static void main(String[] args) {
java.util.Scanner scanner = new java.util.Scanner(System.in);
while(scanner.hasNext()) {
String[] as= {"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[] num= { 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};
int[] nn= {8,7,6,5,4,3,2,1};
int sum=0; //少前兩碼的總和
int sum1=0; //正確總和
int avg=0;
for(int i=0;i<9;i++) {
int r=scanner.nextInt();
if(i != 8) {
sum=sum+r*nn[i];
}else {
avg=10-r;
}
}
for(int i=0;i<25;i++) {
if(((num[i]%10)*9+(num[i]/10)+sum)%10==avg) {
System.out.print(as[i] );
}else {
continue;
}
}
}}
}

請問 為什麼檢查碼是這樣算的? 有點看不懂規則


 
#20136: Re:簡易方法,可以跑,但RE,歡迎指正


z85385637 (M-Kai)

學校 : 樹德科技大學
編號 : 96081
來源 : [180.218.46.214]
最後登入時間 :
2022-10-13 21:14:12
a054. 電話客服中心 -- 板橋高中教學題 | From: [120.119.33.43] | 發表日期 : 2019-12-05 22:50

public class a054 {
public static void main(String[] args) {
java.util.Scanner scanner = new java.util.Scanner(System.in);
while(scanner.hasNext()) {
String[] as= {"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[] num= { 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};
int[] nn= {8,7,6,5,4,3,2,1};
int sum=0; //少前兩碼的總和
int sum1=0; //正確總和
int avg=0;
for(int i=0;i<9;i++) {
int r=scanner.nextInt();
if(i != 8) {
sum=sum+r*nn[i];
}else {
avg=10-r;
}
}
for(int i=0;i<25;i++) {
if(((num[i]%10)*9+(num[i]/10)+sum)%10==avg) {
System.out.print(as[i] );
}else {
continue;
}
}
}}
}

請問 為什麼檢查碼是這樣算的? 有點看不懂規則


沒事 已解^_^


 
ZeroJudge Forum