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;
}
}
}}
}
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;
}
}
}}
}
請問 為什麼檢查碼是這樣算的? 有點看不懂規則
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;
}
}
}}
}
請問 為什麼檢查碼是這樣算的? 有點看不懂規則
沒事 已解^_^