java关于判断证件对错题!ACM!!新手求助!按道理应该输出ALL pass

http://img.mukewang.com/58bf7df40001dee013460579.jpg

http://img.mukewang.com/58bf7df500016f2809970583.jpg


import java.util.*;

public class Main

{

public static void main(String[] args) 

{

Scanner sc=new Scanner(System.in);

int n=sc.nextInt();

char[] a={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};

//int[] z={0,1,2,3,4,5,6,7,8,9,10};

//String m="10X98765432";

char[] m={'1','0','X','9','8','7','6','5','4','3','2'};

String[] f=new String[n];

int k=0,p,sum;

for(int i=1;i<=n;i++)

{

p=0;

sum=0;

String Id=sc.next();

for(int j=0;j<Id.length()-1;j++)

{

if(!(Id.charAt(j)>='0' && Id.charAt(j)<='9'))

{

p=1;

f[k]=Id;

k++;

break;

}

}

System.out.println("p="+p);

System.out.println("k="+k);

if(p!=1)

{

for(int j=0;j<Id.length()-1;j++)

{

int b=Id.charAt(j)-'0';

sum+=b*a[j];

}

sum=sum%11;

System.out.println("模="+sum);

int b=(int)Id.charAt(17)-'0';

System.out.println("b="+b);

System.out.println("m="+m[sum]);

int c=(int)m[sum]-'0';

System.out.println("c="+c);

if(c!=b);

{

f[k]=Id;

k++;

}

}

}

if(k==0)

{

System.out.println("All passed");

}

else

{

for(int i=0;i<k;i++)

{

System.out.println(f[i]);

}

}

}

}


yeyeyy
浏览 1520回答 3
3回答

慕粉4075985

if(c!=b);你这后面多了个分号
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java