如果 A 是 B 的倍数,那么 A/B==0
如果 A + B 是 偶数,那么(A+B)/2==0

解决方案 »

  1.   

    if((A%B)==0 AND (A+B)&2==0)
    {
       
    }
    else
    {}
      

  2.   


    if((A%B)==0 AND ((A+B)%2)==0)
    {
       
    }
    else
    {}
      

  3.   

    if ( (A%B) == 0 && (A+B)%2 == 0 )
    {
       
    }
    else
    {}
      

  4.   


    if((A%B)==0 AND ((A+B)%2)==0)
    {
       
    }
    else
    {}
      

  5.   

    没有AND是&&,应考虑B==0时,要不会有Excpetion
      

  6.   

    对应该考虑b=0
    应该是((B!=0)&&((A/B)==0)&&(((A+B)/2)==0))
    JAVA没有AND 但有&和&&
      

  7.   

    try{
    if(a%b==0 && (a+b)%2==0)
       System.out.println("正确");
    }
    else{
       System.out.println("不正确");
    }
    catch(ArithmeticException e){
       System.out.println("不能除0");
    }
      

  8.   

    public static boolean satisfy(int a, int b) {
       if(b == 0)
          return (a == 0);
       if(a == 0)
          return (b%2 == 0);
       return (a%b == 0) && ((a+b)%2 == 0);
    }
      

  9.   

    if((A!=0)&&(B!=0)&&((A%B)==0)&&((A+B)&2==0))
    {
       
    }
    else
    {}
      

  10.   

    if(B!=0){//B不为0时
    if((A%B)==0&&(A+B)%2==0)
    {
       
    }
    else
    {}
    }//end if(B!=0)不用管A是否为0,只管B是否为0;
      

  11.   

    放到.java里一试就知道啦.........
      

  12.   

    我考虑了除零的问题,为什么不给我分?
    完整例子
    class Test{
    public static void main(String[] args)
    throws IOException{
    int a,b;
    System.in.read(a);
    System.in.read(b);
    try{
    if(a%b==0 & (a+b)%2==0)
    System.out.println("正确");
    }
    else{
    System.out.println("不正确");
    }
    catch(ArithmeticException e){
    System.out.println("不能除0");
    }
    }
    }
    还有需要说明的,如果想使用a%b 和 (a+b)%2运算结果,建议不要使用&&比如
    if( (c=a%b)==0 &&(d=(a+b)%2==0){c=d++ ;}

    if( (c=a%b)==0 &(d=(a+b)%2==0){c=d++ ;}
    的结果可能是不一样的。
    因为 &&前面表达式如果是false那么就不再考虑后面的表达式了  ||的用法相同 当前面的是 true的时候 就不在管后面的操作数的真假了。