如果用read()方法
还需要用skip(2);方法跳过两个字节-跳过回车
因为回车也是输入呀

解决方案 »

  1.   

    public void getint(){       //获取数组
            try{
              for(int i=0;i<10;i++){
                s[i]=System.in.read()-48;
                long a=System.in.skip(2);
              }
            }catch(Exception e){
              System.err.println("caught IOException in getint()");
              e.printStackTrace(System.err);
             }
        }
    达因返回的值是字符的编码值0--48 1--49,所以减48就可以了,read()方法本来就返回int,不用转换!
        public void sort(){    //排序
            int temp;
            for(int j=0;j<9;j++)
                for(int i=j+1;i<10;i++)
                    if(s[j]>s[i]){
                        temp=s[j];
                        s[j]=s[i];
                        s[i]=temp;
                    }
        }
    我把你的排序算法改了一下