Scanner input=new Scanner(System.in);
  int a;
  int b;
  a=input.nextInt();
  b=input.nextInt();
  System.out.printf("%d\n",a);
  System.out.printf("%d\n",b);
上面这样写的话,不知道为什么b的值不管输入的是什么.b永远是a的值但是我只要这样改:
a=input.nextInt();System.out.println();
b=input.nextInt();
这样就正常了...
很不解....希望能有人给我发个解答~谢谢

解决方案 »

  1.   

    我测试是正确的,楼主自己测试不对吗
    public class Test
    {
        public static void main(String[] args)
        {
            Scanner input=new Scanner(System.in); 
            int a; 
            int b; 
            a=input.nextInt(); 
            b=input.nextInt(); 
            System.out.printf("%d\n",a); 
            System.out.printf("%d\n",b); 
        }
    }
      

  2.   

    嗯.我的不对啊```
    我输入15和12
    结果显示了两个15```
    我是在JC下编译的.JDK是1.6的
      

  3.   

    import java.util.Scanner;
    public class remainder
    {
    public static void main(String args[])
    {
    Scanner input=new Scanner(System.in);

    int a;
    int b;
     
     System.out.printf("the first:");
        a=input.nextInt();
        
        System.out.printf("the second:");
        b=input.nextInt();
        
       
        
       if(a%b!=0)      System.out.printf("the first isn's a multiple of the second.");
        else
         System.out.printf("the first is a multiple of the second.");
        
      
    }
    } 这样就又对了`我很疑惑`!