Java Code
import java.util.*;
public class test{
public static void main(String[] args){
Scanner scanner=new Scanner(System.in);
String str;
while(scanner.hasNext()){
str=scanner.nextLine();
calc(str);
}
}
public static void calc(String str){
int[] data={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 sum=0,t;
int c=Integer.parseInt(str.substring(8,9));
for(int j=0;j<str.length()-1;j++){
sum+=Integer.parseInt(str.substring(j,j+1))*(8-j);
}
for(int i=0;i<data.length;i++){
t=sum+(data[i]%10)*9+(data[i]/10)+c;
if(t%10==0){
System.out.print((char)(i+65));
}
}
System.out.println();
}
}
Java Code
import java.util.*;
public class test{
public static void main(String[] args){
Scanner scanner=new Scanner(System.in);
String str;
while(scanner.hasNext()){
str=scanner.nextLine();
calc(str);
}
}
public static void calc(String str){
int[] data={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 sum=0,t;
int c=Integer.parseInt(str.substring(8,9));
for(int j=0;j<str.length()-1;j++){
sum+=Integer.parseInt(str.substring(j,j+1))*(8-j);
}
for(int i=0;i<data.length;i++){
t=sum+(data[i]%10)*9+(data[i]/10)+c;
if(t%10==0){
System.out.print((char)(i+65));
}
}
System.out.println();
}
}
真的:
判斷式應該改為
If ((sum[i]) +檢查碼 ) % 10 == 0{ cout << captial[i]... }
Java Code
import java.util.*;
public class test{
public static void main(String[] args){
Scanner scanner=new Scanner(System.in);
String str;
while(scanner.hasNext()){
str=scanner.nextLine();
calc(str);
}
}
public static void calc(String str){
int[] data={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 sum=0,t;
int c=Integer.parseInt(str.substring(8,9));
for(int j=0;j<str.length()-1;j++){
sum+=Integer.parseInt(str.substring(j,j+1))*(8-j);
}
for(int i=0;i<data.length;i++){
t=sum+(data[i]%10)*9+(data[i]/10)+c;
if(t%10==0){
System.out.print((char)(i+65));
}
}
System.out.println();
}
}
真的:
判斷式應該改為
If ((sum[i]) +檢查碼 ) % 10 == 0{ cout << captial[i]... }
可以參考a020的公式